1.2n-address machines
The idea
The same calculation can be written for CPUs that name 3, 2, 1 or 0 addresses per instruction. Fewer addresses per instruction means more instructions.
Think of it like this: Like giving directions: one long sentence with everything (3-address) versus many short commands, "go, turn, stop" (stack machine).
Why it exists
It is a trade-off between instruction size and program length. Accumulator and stack machines have tiny instructions but need extra moves.
How it works
- 3-address:
ADD T,A,Bnames result and both sources. - 2-address: the destination is also the first source, so you often need a MOV first.
- 1-address: the accumulator is implied, so you LOAD, operate, then STORE.
- 0-address: the stack is implied; PUSH operands, operators act on the top.
Worked example: X = (A + B) × C
3-address: 2 instructions. 2-address: 4. 1-address: 4 (LOAD A, ADD B, MUL C, STORE X). 0-address: 6 (PUSH A, PUSH B, ADD, PUSH C, MUL, POP X).
Now play with it
- →Click Next step to execute the listing line by line, then switch tabs and compare lengths.
ADD T, A, BT ← A + BMUL X, T, CX ← T × C
2 instructions for X = (A + B) × C.
Check yourself
How many instructions does X = (A + B) × C need on a 1-address (accumulator) machine?
Exam notes (the dense version)
3-addr: ADD R1,R2,R3 · 2-addr: ADD R1,R2 (dest = src1) · 1-addr: uses accumulator · 0-addr: stack machine (PUSH/POP, ops on top-of-stack).
Previous year questions: Instruction Formats & Addressing Modes (12)
PYQs are grouped by topic, so this is the full set for Instruction Formats & Addressing Modes; try the ones that match this subtopic. Open all 12 on the topic page.