SLIDE 1 / 10
CSZone.co.uk
OCR H446 · Component 1 · 1.2.4

Addressing Modes

OCR A Level Computer Science · cszone.co.uk
H446 SpecA Level
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.
Immediate & Direct

Immediate and Direct Addressing

Immediate Addressing
The operand IS the actual data value.
LDR R1, #25
R1 ← 25 (the literal value 25 is loaded directly). No memory access needed. Fast but not flexible.
Direct Addressing
The operand is a memory address; the CPU fetches the data from that address.
LDR R1, 200
R1 ← value stored at memory address 200. One extra memory access compared to immediate.
Indirect & Indexed

Indirect and Indexed Addressing

Indirect Addressing
The operand is an address that holds another address (a pointer). Two memory accesses needed.
LDR R1, (200)
Fetch address from mem[200], then fetch the data from that address. Supports dynamic data structures like linked lists.
Indexed Addressing
A base address plus an index register (offset) gives the effective address.
LDR R1, 200(R2)
Effective address = 200 + R2. Ideal for iterating through arrays — increment the index register to access consecutive elements.
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.
Exam Practice
OCR H446 Style · 4 marks
Explain the difference between immediate addressing and indirect addressing. Include an example of each.
[4 marks]
2
Immediate: the operand IS the data value used directly (e.g. LDR R1, #10 loads the value 10 into R1). No memory access is required for the operand — it is embedded in the instruction itself.
2
Indirect: the operand is an address that holds another address (a pointer), and the CPU accesses that second address to obtain the actual data (e.g. LDR R1, (200) first reads address from mem[200], then fetches data from that address). Two memory accesses are needed.
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.
1.2.4b Complete
Well done! ✓
Addressing Modes
Return to lesson to continue