CSC213 ยท 2081 ยท 5 marks
What is instruction format? Explain instruction formats of basic computer and give two examples of each type of instructions.
What is instruction format? Explain instruction formats of basic computer and give two examples of each type of instructions. [5]
Quick answer
An instruction format is the layout or structure that defines how the bits of an instruction word are organized and interpreted by the processor. It specifies the fields within an instruction, such as the opcode, address, and mode bits, so that the control unit can correctly decode and execute each instruction.
Instruction Format: Basic Computer
Definition
In the basic computer, each instruction is 16 bits wide and there are three types of instruction formats.
Three Instruction Formats of Basic Computer
1. Memory Reference Instruction
This type of instruction references a memory location as its operand.
Format (16 bits):
| Bit 15 | Bits 14-12 | Bits 11-0 |
|---|---|---|
| I (Mode) | Opcode (3 bits) | Address (12 bits) |
- Bit 15 (I-bit): Addressing mode indicator
I = 0โ Direct addressing (operand is at the given address)I = 1โ Indirect addressing (given address holds the address of the operand)
- Bits 12-14: 3-bit opcode (can represent up to 7 memory reference instructions, since opcode
111is reserved) - Bits 0-11: 12-bit address field (can address up to 4096 memory locations)
Examples:
| Instruction | Description |
|---|---|
| LDA 457 | Load the content of memory address 457 into the Accumulator (AC) |
| ADD 300 | Add the content of memory address 300 to the Accumulator (AC) |
2. Register Reference Instruction
This type of instruction performs operations on CPU registers (primarily the Accumulator) and does not reference memory.
Format (16 bits):
| Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bits 11-0 |
|---|---|---|---|---|
| 0 | 1 | 1 | 1 | Operation bits (12 bits) |
- Bits 12-14 = 111 and Bit 15 = 0 identifies this as a register reference instruction
- Bits 0-11: Each bit specifies a particular register operation (only one bit is set at a time)
Examples:
| Instruction | Description |
|---|---|
| CLA | Clear the Accumulator (AC โ 0) |
| CMA | Complement the Accumulator (AC โ AC') |
3. Input/Output (I/O) Reference Instruction
This type of instruction handles communication with input/output devices and does not reference memory.
Format (16 bits):
| Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bits 11-0 |
|---|---|---|---|---|
| 1 | 1 | 1 | 1 | Operation bits (12 bits) |
- Bits 12-14 = 111 and Bit 15 = 1 identifies this as an I/O reference instruction
- Bits 0-11: Each bit specifies a particular I/O operation
Examples:
| Instruction | Description |
|---|---|
| INP | Input a character from the input device into AC (bits 0-7) |
| OUT | Output a character from AC (bits 0-7) to the output device |
Summary Table
| Format | Bit 15 | Bits 12-14 | Bits 0-11 | Purpose |
|---|---|---|---|---|
| Memory Reference | 0 or 1 (mode) | Opcode (โ 111) | Address | Access memory operands |
| Register Reference | 0 | 111 | Operation bits | Operate on registers |
| I/O Reference | 1 | 111 | Operation bits | Handle I/O operations |
Key Point: The basic computer distinguishes between the three instruction types during the decode phase (T2) by examining bit 15 and the opcode bits 12-14 of the Instruction Register (IR).
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.