[an error occurred while processing this directive]
Instructions are what tell the microprocessor what it should do. Various instructions take various numbers and types of arguments (for example, the arguments for the add instruction might be the destination and the two numbers to be added). For the sake of simplicity, we will assume an instruction length of 16 bits (nowadays, most processors are VLIW and/or CISC). Depending on processor design, an instruction can take any number of arguments of any type. The list of all of these instructions and their arguments is called an opcode map. The most efficient way of creating such a map is to identify what kind of arguments instructions will take. For example, if we need 15 instructions with 12 bits for arguments, 15 instructions with 8 bits for arguments, and 256 instructions with no arguments at all, our opcode map would look something like the table below.
| Each column contains 4 bits of the instruction | |||
| 0000 | arg | arg | arg |
| 0001 | arg | arg | arg |
| 0010 | arg | arg | arg |
| . | arg | arg | arg |
| . | arg | arg | arg |
| . | arg | arg | arg |
| 1110 | arg | arg | arg |
| 1111 | 0000 | arg | arg |
| 1111 | 0001 | arg | arg |
| 1111 | 0010 | arg | arg |
| 1111 | . | arg | arg |
| 1111 | . | arg | arg |
| 1111 | . | arg | arg |
| 1111 | 1101 | arg | arg |
| 1111 | 1110 | arg | arg |
| 1111 | 1111 | 0000 | 0000 |
| 1111 | 1111 | 0000 | 0001 |
| 1111 | 1111 | 0000 | 0010 |
| 1111 | 1111 | . | . |
| 1111 | 1111 | . | . |
| 1111 | 1111 | . | . |
| 1111 | 1111 | 1111 | 1101 |
| 1111 | 1111 | 1111 | 1110 |
| 1111 | 1111 | 1111 | 1111 |
Each processor has many instructions, and each instruction set can dramatically differ from another. In particular, RISC architectures have very different instruction sets from VLIW processors. The authors have a greater knowledge of the Intel x86 instruction set, therefore it will be discussed more than the others.
Many instructions on the opcode map are devoted to simple tasks such as adding, subtracting, etc. Not only are there many simple instructions like that, but each one requires multiple forms. For example, the mov instruction on the x86 instruction set moves some data from one place to another. As simple as that task may sound, many factors need to be taken into account. The x86 processors provide multiple registers (places on the processor that act as temporary memory locations). It is possible to move from register to register, register to memory, memory to register, value to register, and value to memory (where a value is a number). For each of these, it has to be possible to move different quantities of data at once. the new x86 processors allow to move 8, 16, or 32 bits at once. Thus, there needs to be at least 15 opcodes for move alone. Because of complexities in the x86 instruction set, there are actually more than that, but those will not be discussed.
You have now finished reading all the assembler subsections and can go back to the main assembler page.
[an error occurred while processing this directive]