Instruction Formats
An instruction is a binary pattern designed inside an MP to perform a specific function.
Each instruction has two parts:
- The task to be performed called the operation code (opcode).
- Data to be operated on, called the operand.
Instruction Formats Types
The instruction format is divided into three types:
- One Byte Instruction
- Two Byte Instruction
- Three Byte Instruction
One Byte Instruction
- Includes the opcode and operand in the same byte
- Operand(s) are internal register and are coded into the instruction.
- Requires one memory location.
Example of One Byte Instruction
Instruction | Opcode | Operand | HEX Code | Task |
MOV C, A | MOV | C, A | 4F H | Copy the content of the accumulator in register C |
ADD B | ADD | B | 80 H | Add the contents of registers B to the contents of the accumulator |
CMA | CMA | 2F H | Invert (compliment) each bit in the accumulator |
Two Byte Instruction
- The first byte specifies the opcode and the second byte specifies the operand.
- The source operand is a data byte immediately following the opcode.
- The instruction would require two memory locations to store in memory.
Example of Two Byte Instruction
Instruction | Opcode | Operand | HEX Code | Task | |
MVI A, DATA | MVI | A, DATA | 3E | First Byte | Load an 8-bit data byte in the accumulator |
DATA | Second Byte |
Three Byte Instruction
- The first byte specifies the opcode, and the following two bytes specify the 16-bit address.
- The instruction would require three memory locations to store in memory.
- NOTE: The second byte is the low-order address & the third byte is the higher-order address.
- Opcode + Data Byte (LO) + Data Byte (HO)
Example of Three Byte Instruction
Instruction | Opcode | Operand | HEX Code | Task | |
JMP 2000 H | JMP | 2000 H | C3 | First Byte | Transfer the program sequence to the memory location 2000 H. |
00 | Second Byte | ||||
20 | Third Byte | ||||
LDA D000 H | LDA | DOOO H | 3A | First Byte | Load Accumulator with the contents from memory specify with address |
00 | Second Byte | ||||
D0 | Third Byte |