Unit 2: Instructions and control unit
Computer System Architecture notes · PTU syllabus (BSIT301/BSBC204)
On this page
Unit summary
Instructions tell the CPU what to do, and the control unit makes it happen. This unit covers instruction types — memory-, I/O- and register-reference — the instruction cycle, instruction formats, interrupts and the interrupt cycle, hardwired and micro-programmed control units, and addressing modes.
After this unit you can
- Classify instructions and explain instruction formats
- Explain the instruction and interrupt cycles
- Compare hardwired and micro-programmed control
- Explain addressing modes
PTU syllabus topics
- Instruction types (memory/I/O/register reference)
- instruction cycle
- instruction formats
- interrupt and interrupt cycle
- hardwired and micro-programmed control units
- addressing modes
Topic 1
Instruction types and formats
By number of addresses, instructions are three-address, two-address, one-address (with an accumulator) and zero-address (stack-based). An instruction tells the CPU what to do. It has an opcode (operation) and an address/operand part. In the basic computer, a 16-bit instruction has a 1-bit mode (I), a 3-bit opcode and a 12-bit address.
| Type | How it is identified | Example |
|---|---|---|
| Memory-reference | Opcode 000 to 110; uses a memory address (I = 0 direct, I = 1 indirect) | AND, ADD, LDA, STA, BUN |
| Register-reference | Opcode 111 and I = 0; operates on the accumulator | CLA, CMA, INC, HLT |
| Input/output | Opcode 111 and I = 1; communicates with I/O | INP, OUT, ION, IOF |
Three-address
ADD R1, A, B
Two-address
ADD R1, A
One-address (accumulator)
ADD A
Zero-address (stack)
ADD — operands on the stack
Example
X = (A + B) × C in two formats: three-address — ADD R1, A, B then MUL X, R1, C. One-address — LOAD A, ADD B, MUL C, STORE X, using the accumulator. Zero-address — PUSH A, PUSH B, ADD, PUSH C, MUL, POP X.
Exam tip
Fewer addresses mean shorter instructions but more of them.
Topic 2
The instruction cycle
Each instruction passes through fetch, decode, read effective address (for indirect addressing), execute — and then checks for interrupts before the next instruction.
- 1. Fetch: PC → AR; memory → IR; PC + 1
- 2. Decode: Decode opcode, read mode bit I
- 3. Fetch operand: Read effective address if indirect
- 4. Execute: Carry out the operation
- 5. Check interrupts: Go to interrupt cycle if needed
Example
Fetch in RTL: T0: AR ← PC; T1: IR ← M[AR], PC ← PC + 1; T2: decode IR. If the instruction is ADD with a direct address, the operand is read from memory and added to the accumulator in the execute phase.
Exam tip
Draw the cycle and write the RTL for the fetch phase.
Topic 3
Interrupts and the interrupt cycle
Interrupts are external (from I/O devices), internal (traps such as divide by zero or overflow) or software interrupts (system calls). In the interrupt cycle, the CPU saves the return address, branches to the interrupt service routine and later returns.
- Interrupt: a signal that suspends the current program to service an event (I/O completion, error, timer).
- Types: external (I/O devices), internal (traps — overflow, divide by zero), software interrupts (system calls).
- 1Save the return address (PC)
- 2Branch to the interrupt service routine
- 3Disable further interrupts
- 4Service the interrupt
- 5Restore and return to the program
Example
Handling a keyboard interrupt: while a program runs, a key is pressed. After finishing the current instruction, the CPU saves the PC, jumps to the keyboard service routine to read the key, then restores the PC and continues the program.
Exam tip
The CPU checks for interrupts only at the end of each instruction cycle.
Topic 4
Hardwired and micro-programmed control units
Implementation
Logic gates, decoders, flip-flops
Control memory storing microinstructions
Speed
Faster
Slower
Flexibility
Hard to modify
Easy to change by rewriting microcode
Used in
RISC processors
CISC processors
Design
Complex for large instruction sets
Systematic
Example
Choosing a design: a RISC processor with a small, simple instruction set uses hardwired control for speed. A CISC processor with many complex instructions uses micro-programmed control, because changing the microprogram is easier than redesigning logic circuits.
Exam tip
Hardwired = faster but inflexible; micro-programmed = slower but easy to modify.
Topic 5
Addressing modes
Addressing modes specify how the effective address of an operand is found. They give programmers flexibility with pointers, arrays, loops and constants.
| Mode | Effective address | Example |
|---|---|---|
| Immediate | Operand is in the instruction | ADD #5 |
| Register | Operand is in a register | ADD R1 |
| Direct | Address field gives the operand's address | LDA 500 |
| Indirect | Address field gives the address of the address | LDA (500) |
| Register indirect | Register holds the operand's address | LDA (R1) |
| Indexed | Address + index register | LDA 500(X) |
| Relative | PC + offset | BR +10 |
| Auto-increment and auto-decrement | Register indirect with register updated | LDA (R1)+ |
- Purpose: flexibility for pointers, arrays, loops and relocation; reduce instruction size.
Example
Same instruction, different modes: with R1 = 200 and memory M[200] = 50, M[300] = 200: LOAD #200 loads 200 (immediate); LOAD 200 loads 50 (direct); LOAD @300 loads M[M[300]] = M[200] = 50 (indirect); LOAD (R1) loads M[200] = 50 (register indirect).
Exam tip
Practise effective-address questions with a table — a frequent numerical question.
Key terms
- Opcode
- Part of an instruction specifying the operation
- Instruction cycle
- Fetch, decode, execute sequence
- Interrupt
- Signal that suspends the current program
- Microinstruction
- Control word stored in control memory
- Effective address
- Actual address of the operand
Quick revision
- Memory-, register-, I/O-reference instructions; three-, two-, one-, zero-address formats.
- Fetch, decode, operand fetch, execute.
- Interrupt types and cycle.
- Hardwired vs micro-programmed control.
- Immediate, register, direct, indirect, indexed, relative addressing.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Name the three types of instructions in the basic computer.
- Q2.What is a zero-address instruction?
- Q3.State the steps of the instruction cycle.
- Q4.What happens in the interrupt cycle?
- Q5.Distinguish hardwired and micro-programmed control.
- Q6.Distinguish direct and indirect addressing.
Long-answer questions
- Q1.Explain instruction types and formats.
- Q2.Explain the instruction cycle and interrupt cycle.
- Q3.Compare hardwired and micro-programmed control units.
- Q4.Explain addressing modes with examples.
Stuck on this unit?
Message SBS on WhatsApp for help with Computer System Architecture, or to ask about studying B.Sc IT at Synetic.
