A-Level Computer Science / Unit 4: CPU Operation and Low-Level Processing

4.2.3 Finding Data: Addressing Modes

🔒 Lesson slides are available to signed-in users. Sign in

4.2.3 Finding Data: Addressing Modes

An instruction's operand does not always contain the value that the processor will use. Depending on the addressing mode, the operand might be a value, an address, a pointer to another address, or part of an address calculation.

By the end of this section, you should be able to:

  • Explain how an addressing mode controls the interpretation of an operand.
  • Use immediate, direct, indirect, indexed and relative addressing.
  • Calculate an effective address when a register or offset is involved.
  • Trace the memory accesses needed by each mode.
  • Distinguish an address from the data stored at that address.
  • Explain how symbolic and absolute address forms relate to addressing modes.
  • Select a suitable addressing mode for a simple low-level programming situation.

How Does the Processor Interpret the Operand?

Addressing mode: the rule that tells the processor whether an operand is the required value or how the address of the required value should be found.

A useful intermediate idea is the effective address: the final memory address from which data will be read or to which data will be written.

Effective address: the memory address obtained after the addressing-mode rule has been applied.
Mode What the operand represents How the required value is obtained
Immediate The value itself Use the operand directly.
Direct The address of the value Read the value from that address.
Indirect An address holding another address Follow the pointer, then read the value.
Indexed A starting address Add IX to form the effective address.
Relative An offset from a base Add the offset to the selected base address.
Common misconception: An operand is not always data. In several modes, it is used to locate the data.

Shared Memory Model for the Examples

Every worked example on this page uses the following independently created memory state:

Memory address Stored content Possible role in the examples
30044Ordinary data
301305Pointer to address 305
30218Starting location for indexed addressing
30372Ordinary data
3049Direct-addressing target
30563Indirect-addressing target
30627Indexed-addressing target
30791Relative-addressing target
30812Ordinary data
Index Register (IX) 4
Base Register (BR) 300
Accumulator before each example 0

The registers are reset to these starting values before each separate example.

Immediate Addressing: Use the Operand as the Value

With immediate addressing, the instruction contains the value to use. No additional data-memory lookup is needed after the instruction has been fetched.

LDM #26 ACC ← 26

In the syllabus instruction notation, a literal can be represented in denary, binary or hexadecimal. These three operands all represent the same value:

Source notation Number base Denary value
#26Denary26
B00011010Binary26
&1AHexadecimal26
Immediate addressing: the operand is the actual value used by the instruction.
Common mistake: #26 means the value 26. It does not mean “read the content of memory address 26”.

Direct Addressing: The Operand Is the Data Address

In direct addressing, the operand gives the address where the required value is stored.

Instruction LDD 304
Effective address 304
Memory content memory[304] = 9
Result ACC = 9
Direct addressing: the operand is the address of the location containing the required value.

Indirect Addressing: Follow a Pointer

In indirect addressing, the operand points to a memory location that stores a second address. The processor follows that address to find the data.

Instruction LDI 301
First lookup memory[301] = 305
Second lookup memory[305] = 63
Result ACC = 63
Indirect addressing: the operand identifies a location containing the address of the required value.
Common mistake: For LDI 301, the value 305 is an address to follow. It is not the final value loaded into ACC.

Indexed Addressing: Add the Index Register

Indexed addressing calculates the effective address by adding the content of IX to the address in the instruction. It is particularly useful when stepping through a sequence such as an array or table.

Instruction address 302 + IX 4 = Effective address 306
LDX 302 memory[306] = 27 ACC = 27
Indexed addressing: the effective address is formed by adding the instruction's address operand to the content of IX.

Relative Addressing: Add an Offset to a Base

Relative addressing identifies a location by adding an offset to a base address. In this teaching model, the base address is held in BR.

BR 300 + Offset 7 = Effective address 307
LDD [BR] + 7 memory[307] = 91 ACC = 91
Relative addressing: the effective address is calculated from a base address plus an offset.

Real processors may define the base for relative addressing differently. The notation above is an explicit teaching model that makes the address calculation visible.

Symbolic and Absolute Addresses: Source Forms, Not Two Extra Modes

The old page grouped symbolic, relative and absolute addressing together. For the syllabus-based structure, an important distinction is needed:

  • Symbolic address: a label written by the programmer, such as PRICE.
  • Absolute address: the numerical memory address, such as 304.
  • Addressing mode: the rule the processor uses to interpret the operand.

Suppose the assembler's symbol table contains PRICE → 304:

Source form What the assembler does Processor behaviour
LDD PRICE Replace PRICE with address 304. Direct addressing reads memory[304].
LDD 304 The numerical address is already present. Direct addressing reads memory[304].
Common misconception: “Symbolic” describes how an address is written in assembly source. It does not replace the need to identify whether the processor uses immediate, direct, indirect, indexed or relative addressing.

Comparing the Five Modes

Mode Example Effective-address rule Result in this memory model Data-memory reads after fetch
Immediate LDM #26 No effective address ACC = 26 0
Direct LDD 304 EA = 304 ACC = 9 1
Indirect LDI 301 EA = memory[301] = 305 ACC = 63 2
Indexed LDX 302 EA = 302 + IX = 306 ACC = 27 1
Relative LDD [BR] + 7 EA = BR + 7 = 307 ACC = 91 1

The memory-read counts above exclude the fetch of the instruction itself and describe this simplified teaching model.

Interactive: Effective Address Visualiser

Select a mode and follow the operand from the instruction to the final ACC value. The memory cells and register values update at each stage.

Instruction operand #26

The operand is already the required value.

Effective address or rule No address needed

Immediate mode does not perform a data-address calculation.

Value loaded into ACC 26

The literal value is copied directly to ACC.

Instruction LDM #26
IX 4
BR 300
ACC 0

Memory

30044
301305
30218
30372
3049
30563
30627
30791
30812

Immediate value

Operand 26 Value used 26 = ACC 26

The operand itself is the value, so no data-memory address is calculated.

Step 1 of 4: read the operand

Common Mistakes and Misconceptions

  • Immediate mode uses the operand as data; direct mode uses it as an address.
  • Indirect mode needs two data-memory lookups in this model: one for the pointer and one for the value.
  • Indexed mode adds IX to the address operand; it does not add IX to the stored data.
  • Relative mode adds an offset to a base address; the offset is not itself the final address.
  • A pointer stores an address, even though that address is represented as an ordinary binary number in memory.
  • A symbolic label is resolved by the assembler and should not be confused with a separate processor addressing mode.
  • Always distinguish the effective address from the content stored at that address.

Exam Tips

For direct, indirect, indexed or relative questions

  1. Write the operand from the instruction.
  2. Apply the mode's rule to obtain the effective address.
  3. Read the content stored at that address.
  4. State the final register value.
Show every lookup: For indirect addressing, write both memory[operand] and memory[effective address].
Use precise vocabulary: “address”, “content”, “pointer”, “offset” and “effective address” are not interchangeable.

Practice

Core questions

  1. Explain the difference between immediate and direct addressing.
  2. Trace LDI 301 using the memory model on this page.
  3. Calculate the effective address for LDX 303 when IX contains 4.
  4. Calculate the effective address for LDD [BR] + 8 when BR contains 300.
  5. Explain why indirect addressing can be described as following a pointer.
  6. Explain why indexed addressing is useful when accessing array elements.
  7. Explain how LDD PRICE can still use direct addressing.

New memory challenge

Use this separate memory state:

AddressContent
41077
411414
41223
41358
41431
41586

If IX contains 3 and BR contains 410, find the ACC value after each independent instruction: LDM #14, LDD 413, LDI 411, LDX 412 and LDD [BR] + 5.

Review

Mode Rule to remember
ImmediateOperand = value
DirectOperand = address of value
IndirectOperand = address of pointer
IndexedEffective address = operand + IX
RelativeEffective address = base + offset
Final check: Can you state, for each mode, whether the operand is data, an address, a pointer location, a starting address or an offset?