1.5Why each mode exists
The idea
Each addressing mode exists because it makes one common programming job cheap: constants, variables, pointers, arrays, relocatable code, loops.
Think of it like this: Different tools for different jobs: a ruler for lengths, a compass for circles.
Why it exists
Without them every array access or pointer follow would need several extra instructions.
How it works
- Constants → immediate. Global variables → direct. Pointers → indirect / register indirect.
- Arrays → indexed (base address in the instruction, index in a register). Relocation → base register.
- Branches and position-independent code → relative. Walking arrays or stacks → auto-increment.
Worked example: Summing an array
The one instruction ADD ACC, 100(X) adds element X of the array at 100. Just bump X each iteration: 5, 8, 2, 9 → sum 24.
Now play with it
- →Press Next step and notice only the index register X changes while the instruction stays identical.
- X = 0: EA = 100, ACC += M[100]
- X ← X + 1 (the only thing that changes)
- EA = 101, ACC += M[101]
- X = 2: EA = 102, ACC += M[102]
- X = 3: EA = 103, ACC += M[103]. Array summed with one instruction pattern.
Indexed mode: the same instruction (EA = 100 + X) walks the array just by changing X.
Check yourself
Which addressing mode is the natural fit for reading a[i] inside a loop?
Exam notes (the dense version)
Immediate → constants. Direct → globals. Indirect → pointers. Indexed → arrays (A = base, X = index). Base-register → relocation / segments. Relative → position-independent code & branches. Auto-inc → stepping through arrays/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.