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
- 1. Fetch: Get instruction from memory
- 2. Decode: Work out what it means
- 3. Fetch operands: Get the data needed
- 4. Execute: Carry out the operation
- 5. Check interrupts: Handle if pending
Topic 1
Instruction types and formats
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
Topic 2
The instruction cycle
- 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
Topic 3
Interrupts and the interrupt cycle
- 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
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
Topic 5
Addressing modes
| 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.
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.
