4.1.8 · D3Computer Architecture (Deep)

Worked examples — Memory addressing modes — immediate, register, direct, indirect, indexed

2,063 words9 min readBack to topic

The scenario matrix

Every worked example below is tagged with the cell of this matrix it covers. The goal: hit all of them.

Cell Case class What makes it tricky
C1 Immediate — a plain constant Zero memory access; operand is the bits
C2 Register — operand already inside CPU No bus trip; contrast with memory modes
C3 Direct — literal address Baseline "1 read" case
C4 Indirect — pointer chase (2 reads) Distinguish from
C5 Indexed — forward array walk , positive index
C6 Indexed — zero index (degenerate) EA , same cell as direct
C7 Indexed — negative index (backward) Signed index, walking down an array
C8 Limiting / wrap — address near memory top Address arithmetic modulo memory size
C9 Word problem — real array loop Choosing the right mode
C10 Exam twist — mixed indirect + indexed Order of operations trap

The shared machine state for the examples (unless a problem overrides it):

The figure above is the mental model for every example: an address is just a house number on a street, and each mode is a different clue for finding the right house.


Worked examples

C1 — Immediate (constant, 0 accesses)


C2 — Register (0 accesses, contrast the bus)


C3 — Direct (literal address, 1 read)


C4 — Indirect (pointer chase, 2 reads)


C5 — Indexed forward (positive index, 1 read)


C6 — Indexed with zero index (degenerate → equals direct)


C7 — Indexed with negative index (walk backward)


C8 — Limiting case: address wrap-around at memory top


C9 — Word problem: sum an array (choosing the mode)


C10 — Exam twist: indirect through an index (order matters)


Recall Quick self-check on the matrix

Which cells produce the same EA, and why? ::: C3 (direct [100]) and C6 (indexed [100+R3], R3=0) both give EA=100 — indexed with a zero index degenerates into direct. Why does C8 wrap 260 down to 4? ::: The 8-bit adder drops the carry, so EA = 260 mod 256 = 4. In C10, why 2 reads not 1? ::: Indirect always adds one extra memory read to fetch the pointer before fetching the operand; the index add is arithmetic (free), so total = 2. Negative index in C7 — does EA rise or fall? ::: Falls: 204 + (−8) = 196, walking backward through the array.