Lesson Objective
- Understand the term Instruction Set.
- Know that an instruction set is processor specific.
- Understand the components of an instruction set.
- Explain and apply immediate and direct addressing modes.
KS3, GCSE, A-Level Computing Resources
Computer processors have different ways of expressing instructions.
An instruction set describes the commands a processor can perform.
Different types of processors have their own instruction sets but they may perform similar or identical operations.
Instructions may have the following types of commands:
The instruction set defines all the instructions and how they are represented.
Instructions are combinations of binary 1s and 0s; the number of bits used depends on the WORD LENGTH of the processor. A typical WORD LENGTH for operating systems is 64 bits currently.
This is known as machine code and is the only language the processor can understand.
Each instruction has a unique machine code equivalent, for example a very basic processor might hold each instruction in a single byte:
Machine Code | Instruction | Example |
---|---|---|
0000 1111 | STORE | STO 15 |
0010 11110 | LOAD | LDA 15 |
0100 1111 | ADD | ADD 15 |
1000 1111 | SUB | SUB |
1111 0000 | HALT | STOP |
An instruction typically includes two parts:
The number of bits allocated to the opcode and operand will vary according to the processor used. Manufacturers decide the amount of bits allocated within the WORD SIZE to the OPCODE and OPERAND. The example below shows a possible arrangement for an instruction used in a processor with a 16-bit word length.
Machine Code | |
---|---|
0110 0001 0101 1100 | |
0110 | 0001 0101 1100 |
Opcode | Operand |
The Opcode denotes the basic machine operation (instruction) e.g. ADD, LOAD, STORE.
The Operand represents one item of data or the address of one item of data.
This simple model shows the addressing mode, which is usually 2 bits. It specifies if the data is a value, address or register.
Machine Code | ||
---|---|---|
0110 0001 0101 1100 | ||
Opcode | Operand | |
0110 | ||
Machine operation | Addressing mode | |
011 | 0 | 0001 0101 1100 |
Below is an example of a 16 bit instruction. The operand is the actual value to be used in the instruction.
Addressing mode 00 says the data value of 3 is not an address.
Machine Code | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
Opcode | Operand | ||||||||||||||
Machine operation | Addressing mode | ||||||||||||||
1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
The operand holds the memory address of the value to be operated on.
Addressing mode 01 says that the data is an address, not a value.
Machine Code | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
Opcode | Operand | ||||||||||||||
Machine operation | Addressing mode | ||||||||||||||
1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |