🔒 Pro · Component 1 · 1.2.4 Types of Programming Language
1.2.4b Addressing Modes
OCR H446 · A Level Computer Science · ~10 min read
Notes
—
Video
—
Slides
—
Worksheet
—
Quiz
What are Addressing Modes?
An addressing mode specifies how the operand part of a machine code instruction identifies the actual data to be used. Different addressing modes allow the operand to refer to data in different ways — as a literal value, a memory address, or a register.
OCR H446 requires knowledge of four main addressing modes: immediate, direct, indirect, and indexed.
1. Immediate Addressing
The operand is the actual data value to be used. The value is embedded directly in the instruction itself — no memory lookup is needed.
How it works: the instruction contains the literal value to use (e.g. the number 5).
Example:MOV R1, #5 — the value 5 is placed directly into R1. The # symbol indicates immediate addressing in many assembly languages.
Advantage: fast — no memory access required to fetch the data.
Disadvantage: the value is fixed — it cannot change during program execution. Limited to small constants.
Use case: loading constants or small literal values (e.g. setting a counter to 0, comparing to a fixed threshold).
2. Direct Addressing
The operand contains a memory address. The CPU accesses that address in memory to retrieve the actual data.
How it works: the operand is a memory address; the CPU goes to that address to get the data value.
Example:LDR R1, 200 — load the value stored at memory address 200 into R1.
Advantage: can access any location in memory; the value at that address can change during program execution.
Disadvantage: requires one memory access to fetch the data (slower than immediate); the address is fixed in the instruction.
Use case: accessing a specific named variable stored at a known memory location.
3. Indirect Addressing
The operand contains a memory address, but that address holds another address — the actual data is at the second address. The CPU must make two memory accesses.
How it works: operand → memory address A → value at A is another address B → actual data is at B.
Example:LDR R1, (200) — go to address 200, read what is there (say, address 350), then go to address 350 to get the actual data.
Advantage: the pointer (address stored at the operand address) can be changed at runtime, so indirect addressing supports dynamic data access — e.g. pointers in C, implementing linked lists, passing arrays by reference.
Disadvantage: requires two memory accesses — slower than direct addressing.
Use case: pointer-based data access, implementing dynamic data structures.
4. Indexed Addressing
The operand contains a base address. An index register (e.g. IX) holds an offset value. The effective address is calculated as: base address + index register value.
How it works: effective address = base address (in instruction) + value of index register (IX).
Example:LDR R1, 200, IX where IX = 3 → effective address = 200 + 3 = 203 → load value from address 203 into R1.
Advantage: by incrementing the index register, the same instruction can access successive memory locations — ideal for iterating through arrays.
Disadvantage: requires an additional register (the index register) and a calculation to determine the effective address.
Use case: iterating through arrays and sequential data structures — the index register acts as the array index.
Summary Comparison Table
Mode
Operand Contains
How Data is Found
Memory Accesses
Main Use
Immediate
Actual data value
Data is in the instruction itself
0 (no memory access)
Constants, literals
Direct
Memory address
Data is at the specified address
1
Named variables
Indirect
Address of an address (pointer)
Address A → read pointer → go to pointer address for data
2
Pointers, dynamic structures
Indexed
Base address; index register holds offset
Data is at (base + IX)
1 (plus address calc)
Array access, loops
Memory Map Example
Suppose memory contains:
Address
Value stored
200
350
201
42
202
99
350
17
Immediate:MOV R1, #200 → R1 = 200 (the number 200 itself).
Exam tip: Know the four addressing modes clearly: immediate (data in instruction), direct (address in instruction — one memory access), indirect (address of address — two memory accesses), indexed (base + index register offset). Expect questions asking you to identify the mode used in an instruction, or to trace through what a program does.
Exam tip: Immediate is the fastest (no memory access). Indirect is the slowest (two memory accesses). Indexed is most useful for arrays. Remember: indirect needs a pointer stored in memory; indexed uses a register as the offset.
⚠ Common Mistakes
Confusing immediate and direct — immediate: the operand IS the value (e.g. MOV R1, #5). Direct: the operand is an ADDRESS and you go to memory to get the value (e.g. LDR R1, 200).
Saying indirect only needs one memory access — indirect needs TWO: first to get the pointer, second to get the actual data.
Confusing indirect and indexed — indirect uses a pointer stored in memory (two accesses). Indexed uses a register holding an offset, added to a base address (one access + calculation).
✓ Notes completed!
▶
Video coming soon
Click to advance · Arrow keys also work
Click slide or press arrow keys to navigate
✍
Worksheet — 1.2.4b Addressing Modes
8 questions · 20 marks · instantly marked
Q1Explain what is meant by an 'addressing mode' in the context of assembly language/machine code instructions.[2 marks]
✓ Mark scheme
An addressing mode specifies how the operand part of a machine code instruction identifies the actual data to be used [1]; different modes allow the operand to specify the data directly (as a literal), as a memory address, as the address of an address, or as a base address combined with a register offset [1].
Q2Distinguish between immediate addressing and direct addressing. Give one assembly instruction example of each.[4 marks]
✓ Mark scheme
Immediate: the operand is the actual data value — no memory access is required [1]; example: MOV R1, #5 — the value 5 is placed directly into R1 [1]. Direct: the operand is a memory address — the CPU accesses that address to retrieve the data value (one memory access) [1]; example: LDR R1, 200 — the CPU goes to memory address 200 and loads whatever value is stored there into R1 [1].
Q3Memory contains: address 300 → value 450, address 450 → value 72. Trace what value would be loaded into R1 by the instruction LDR R1, (300), assuming indirect addressing.[3 marks]
✓ Mark scheme
The operand 300 is a memory address — the CPU goes to address 300 first [1]; address 300 contains the value 450, which is treated as a pointer to another address [1]; the CPU then goes to address 450, which contains 72 — so R1 = 72 [1].
Q4Explain how indexed addressing works and describe a scenario where it would be particularly useful. State how the effective address is calculated.[3 marks]
✓ Mark scheme
In indexed addressing, the effective (actual) address is calculated as: base address (in the instruction) + value of the index register (IX) [1]; by incrementing the index register on each iteration of a loop, successive memory locations can be accessed using the same instruction [1]; useful scenario: iterating through an array — the base address is the start of the array and the index register holds the current element index/offset [1].
Q5Compare the number of memory accesses required for each of the four addressing modes and explain why this matters for performance.[3 marks]
✓ Mark scheme
Immediate: 0 memory accesses — data is in the instruction itself; Direct: 1 memory access; Indexed: 1 memory access (plus address calculation); Indirect: 2 memory accesses [1]; performance matters because each memory access adds latency to instruction execution — accessing RAM is slow compared to CPU speed [1]; immediate addressing is therefore fastest; indirect is slowest due to two sequential memory reads [1].
Q6An array of integers starts at memory address 500. A programmer wants to access element 4 (0-indexed). With indexed addressing, if the base address in the instruction is 500, what must the index register contain? What effective address is used?[2 marks]
✓ Mark scheme
The index register must contain 4 (the offset of element 4 from the base address) [1]; effective address = 500 + 4 = 504 — the CPU will access memory address 504 to read the value of array element 4 [1].
Q7Explain why indirect addressing is useful for implementing dynamic data structures or passing arrays as parameters in programming.[2 marks]
✓ Mark scheme
Indirect addressing allows the pointer (the address stored in memory) to be changed at runtime — so the same instruction can access different memory locations depending on what the pointer currently points to [1]; this is how pointers in C work and how linked lists can be traversed: you follow a chain of addresses rather than accessing fixed memory locations [1].
Q8Give one advantage and one disadvantage of immediate addressing compared to direct addressing.[2 marks]
✓ Mark scheme
Advantage: immediate is faster — no memory access is required because the value is encoded directly in the instruction [1]; disadvantage: the value is fixed at the time the instruction is written and cannot be changed at runtime — only suitable for constants [1]; direct addressing is more flexible because the value stored at the memory address can change during execution.
Topic Quiz
1 of 15
You scored
out of 15
🎯
Mini Test — 1.2.4b Addressing Modes
10 questions · 10 marks · 10 minutes
5 MCQ + 5 short answer
⏱10:00
10 marks
Section A — Multiple Choice
Q1In immediate addressing, the operand of the instruction contains:
Q2How many memory accesses are required in indirect addressing to retrieve the data?
Q3Which addressing mode is most efficient for iterating through an array in a loop?
Q4Memory: address 100 → value 250, address 250 → value 33. Using indirect addressing, LDR R1, (100) loads R1 with:
Q5With indexed addressing, base address = 400, index register IX = 5. What is the effective address?
Section B — Short Answer
Q6What is immediate addressing? Give one advantage.
Mark schemeThe operand contains the actual data value — no memory access needed. Advantage: fast execution since the data is in the instruction itself. [1 mark]
Q7How is the effective address calculated in indexed addressing?
Mark schemeEffective address = base address (in the instruction) + value of the index register (IX). [1 mark]
Q8Why does indirect addressing require two memory accesses?
Mark schemeFirst access: the CPU reads the memory address in the operand to get a pointer (another address). Second access: the CPU reads the pointer address to retrieve the actual data. [1 mark]
Q9State the addressing mode used in: LDR R1, 500
Mark schemeDirect addressing — the operand (500) is a memory address; the CPU accesses that address to retrieve the data. [1 mark]
Q10Give one advantage of indirect addressing over direct addressing.
Mark schemeThe pointer stored in memory can be changed at runtime, so the same instruction can access different data locations — enabling dynamic/flexible data access (e.g. implementing pointers, linked lists, passing arrays by reference). [1 mark]