Learning Objectives
By the end of this topic you will be able to:
Define addressing modes in the context of assembly language
Explain immediate, direct and indirect addressing
Explain indexed and relative addressing
Identify which mode is being used from an instruction and state the effective address or value retrieved
What are Addressing Modes?
Why Addressing Modes Exist
An addressing mode specifies how the operand of an instruction should be interpreted — it tells the CPU whether the operand is the actual data, a memory address holding the data, or something calculated at runtime.
The same opcode (e.g. LDR) can work with different addressing modes depending on the operand format, giving low-level programmers flexibility in how data is accessed.
Understanding addressing modes is essential for writing efficient assembly programs and for understanding how high-level constructs like arrays and pointers are implemented at the machine level.
Relative Addressing
Relative (PC-Relative) Addressing
Relative addressing specifies the operand address as an offset from the current value of the Program Counter (PC). The effective address = PC + offset.
Used in branch instructions — instead of specifying an absolute memory address to jump to, the CPU jumps by a fixed number of instructions forward or backward from the current position.
Position-independent code: code using relative addressing can be loaded anywhere in memory and still function correctly, since branches are relative to the current instruction rather than an absolute address.
Example: B +3 means jump forward 3 instructions from the current PC position.
Common Mistakes
Don’t Lose Marks
!
Confusing immediate with direct — in immediate the number IS the data; in direct the number is an address pointing to the data in memory. #10 means the value 10; 10 (without #) means address 10.
!
Forgetting that indirect requires TWO memory accesses — one to read the pointer and one to read the actual data. Students often describe it as a single fetch.
!
Saying relative addressing is the same as direct — relative uses the PC as a base and specifies an offset; it does not specify an absolute memory address. This makes code position-independent.