Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Understanding addressing modes is fundamental to mastering computer architecture because they reveal how the CPU actually locates and retrieves data during instruction execution. You're being tested on the trade-offs between speed, flexibility, and memory efficiency, concepts that appear throughout processor design, from instruction encoding to cache optimization. When an exam asks about performance implications or why certain code patterns exist, addressing modes are often the underlying answer.
Don't just memorize the syntax of each mode. Focus on when and why each mode is optimal: What problem does it solve? What's the cost in clock cycles or instruction size? The best exam answers connect addressing modes to broader concepts like instruction cycle efficiency, data structure implementation, and position-independent code.
These modes prioritize execution speed by keeping operands in the fastest storage locations, either embedded in the instruction itself or stored in registers. The key principle: fewer memory accesses mean faster execution.
The operand is embedded directly in the instruction, so no memory fetch is required. This makes it the fastest addressing mode.
MOV R1, #5)The operand lives in a CPU register, the fastest accessible storage in the memory hierarchy.
Compare: Immediate vs. Register Addressing: both avoid memory access for speed, but immediate embeds a fixed value in the instruction while register addressing references a variable value that can change at runtime. If you're loading a constant, use immediate. If you're doing arithmetic on a value that changes, use register.
These modes access main memory by specifying addresses directly or through a single level of indirection. The trade-off: simpler addressing logic but slower execution due to memory access latency.
The memory address is hardcoded in the instruction itself. The CPU reads that address and fetches the operand in one memory access.
The instruction doesn't contain the data's address directly. Instead, it points to a register or memory location that holds the address of the data.
Compare: Direct vs. Indirect Addressing: direct is faster (one memory access) but inflexible since the address is fixed at compile time. Indirect adds a memory fetch but supports dynamic data structures. When you need to implement pointers or traverse a linked list, indirect addressing is the right tool.
These modes calculate the effective address by combining a base value with an offset or index. The general formula is:
This enables efficient access to structured data like arrays, structs, and records.
A base register holds a starting address, and a constant offset is added to reach a specific location. For example, LOAD R1, 100(R2) means "go to the address in R2, move forward 100 bytes, and load what's there into R1."
A base address is combined with a variable index stored in a register. For example, LOAD R1, (R2 + R3) adds the contents of R2 and R3 to compute the target address.
Compare: Base Register vs. Indexed Addressing: both compute addresses, but base register uses a constant offset (good for struct fields that don't move) while indexed uses a variable index (good for iterating through array elements). If an exam asks which mode suits arrays vs. records, this is the distinction.
These modes support branching, function calls, and local variable management. They're how high-level constructs like loops, conditionals, and recursion get implemented at the hardware level.
An offset is added to the program counter (PC) to compute the target address:
BEQ +8 means "if equal, jump 8 bytes forward from the current PC"Operands are accessed implicitly through the stack pointer (SP). Push and pop operations automatically update the address.
Compare: Relative vs. Stack Addressing: relative addressing handles horizontal control flow (jumps and branches within a sequence) while stack addressing handles vertical control flow (diving into and returning from function calls). Both enable modular, position-independent code but serve different structural purposes.
| Concept | Best Examples |
|---|---|
| Fastest execution (no memory access) | Immediate, Register |
| Fixed memory locations | Direct Addressing |
| Dynamic/pointer-based access | Indirect Addressing |
| Struct/record field access | Base Register Addressing |
| Array traversal and iteration | Indexed Addressing |
| Position-independent branching | Relative Addressing |
| Function calls and recursion | Stack Addressing |
| Computed effective address | Base Register, Indexed, Relative |
Which two addressing modes avoid memory access entirely, and why does this matter for execution speed?
You're implementing a linked list traversal. Which addressing mode is essential, and what's the performance cost compared to direct addressing?
Compare base register addressing and indexed addressing: if you're accessing the third field of a struct vs. the third element of an array, which mode fits each scenario?
Why does relative addressing enable position-independent code, and what instruction type most commonly uses it?
Explain how a function call stores its return address and local variables. Which addressing mode and data structure are involved, and what memory access pattern do they use?