[an error occurred while processing this directive]
This section provides an overview of a basic assembler language, as well as the way a microprocessor works in a software perspective. If you find that this overview is not enough to satisfy your curiosity, consider looking at Structured Computer Organization written by Andrew S. Tanenbaum. This book is used at Thomas Jefferson High School for Science and Technology for the Computer Architecture course as well as at various universities.
Before going into the details of assembler, you need to understand certain concepts. We have divided these concepts into sections, so that if you feel that you have a complete understanding of the topic, you can go on to the next one.
The assembler language is especially tailored towards a certain processor. Each assembler command maps to a certain opcode. Unfortunately, a fully fledged assembly language is entirely beyond the scope of this web-site. We will present a much more simplified assembler, which is somewhat similar to the x86 assembler. We have also written a Java applet that will execute assembler instructions that are discussed in this section.
Before explaining the assembler language, it is first important to understand the following:
Registers are small pieces of memory that are right on the CPU. Registers are much faster than memory, and thus it is preferable to use them. On a CPU, there can be any number of registers. The emulator has 8 registers that are called a,b,...,h. Each one of these registers can contain 8 bits. The unsigned value is placed next to the bits for your convenience. Thus, if you put a negative number into one of the registers, a positive number will be displayed.
Memory is RAM. Memory is much slower than registers, because of the access speeds and because of the distance between it and the processor. Currently, there are two kinds of RAM: SIMM and DIMM. We will not try to explain the difference between these two, but the access time on SIMM's is between 70ns and 60ns (1ns=1billionth of a second), while the access time on new DIMM's (SDRAM) is about 8ns. Needless to say, the access time has been dramatically lowered, but there is still room for improvement.
Although stacks are part of memory you can think of them as objects. There are two operations that can be applied to a stack. The first one is "push," and the other one is "pop." When you push something onto a stack, it stays on top. When you pop something off of the stack, you take the top item off. Thus, the stack uses a FILO (First In Last Out) approach.
Now that you are armed with these concepts, we can go on teaching you our assembly language. One of the many things that you can do with a microprocessor is move things around. In our assembly language this instruction will be called "mov." When you use the mov instruction, you first need to specify the destination (i.e. where to move data to), and then the source (i.e. where to move the data from). Thus, a valid instruction would be "mov b, a" (notice the comma that separates the destination and the source), which would move the data stored in register a into register b. The destination can either be a register or memory, while the source can be either memory, register, or pure number. When referring to a memory address, you will need to put brackets ([ ]) around the number of the memory address. Pure numbers do not need any special formatting.
Other instructions very similar to mov are available in our language. These are add, sub, and, or, xor. All of these follow the format of mov. Their purpose should be obvious. There are three more instructions that are contained in our set. "not" only takes one argument, and will store the boolean NOT of the value contained in the specified register or memory address. The other two refer to the stack. "push" and "pop" will push and pop things on and off of the stack. They each take one argument. push takes a register, memory address, or pure number that will be put on top of the stack. pop takes a register or memory address into which the top value of the stack will be stored.
In case you still are not sure as to how to use some of these instructions, we present here all the instructions supported by our emulator.
Moves the source to the destination (the destination being the first argument, and the source being the second).
Adds the source to the destination and stores the result in the destination.
Subtracts the source to the destination and stores the result in the destination.
Boolean ANDs the source and the destination and stores the result in the destination.
ORs the source and the destination and stores the result in the destination.
XORs the source and the destination and stores the result in the destination.
NOTs its one argument and stores the result in the same place.
Shifts left the first argument by the number of bits specified by the second argument.
Shifts right the first argument by the number of bits specified by the second argument.
Pushes its argument onto the stack.
Pops the top item of the stack into its argument.
The emulator is below. You can enter one command at a time. You will see the results of your operation in one of the three colored boxes (depending upon the nature of the operation). This emulator should help you understand topics discussed earlier. For further investigation, look into one of the x86 assembler tutorials.
To start you off, we present a simple set of instructions which will multiply a number by 20. What you see in parentheses are comments that should help you understand how this program works.
mov a, 5 (put the original number into a)
push b (save b by pushing it onto the stack, in case it contained some useful value)
mov b, a (make a copy of a and put it into b)
shl a, 4 (shift a 4 bits to the left, which is the same as multiplying by 16, or 2^4)
shl b, 2 (shift b 2 bits to the left, which is the same as multiplying by 4, or 2^2)
add a, b (add b into a, which makes a equal to 5*16+5*4, which is 5*20)
pop b (restore b from the stack to its original value)
[an error occurred while processing this directive]
Note: You will need a Java 1.1 compliant browser, such as IE 4.0+, and Netscape 4.5+.