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?
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.
| 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. |
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 |
|---|---|---|
| 300 | 44 | Ordinary data |
| 301 | 305 | Pointer to address 305 |
| 302 | 18 | Starting location for indexed addressing |
| 303 | 72 | Ordinary data |
| 304 | 9 | Direct-addressing target |
| 305 | 63 | Indirect-addressing target |
| 306 | 27 | Indexed-addressing target |
| 307 | 91 | Relative-addressing target |
| 308 | 12 | Ordinary data |
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 |
|---|---|---|
#26 | Denary | 26 |
B00011010 | Binary | 26 |
&1A | Hexadecimal | 26 |
#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.
LDD 304
304
memory[304] = 9
ACC = 9
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.
LDI 301
memory[301] = 305
memory[305] = 63
ACC = 63
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.
LDX 302
memory[306] = 27
ACC = 27
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.
LDD [BR] + 7
memory[307] = 91
ACC = 91
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]. |
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 |
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.
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
- Write the operand from the instruction.
- Apply the mode's rule to obtain the effective address.
- Read the content stored at that address.
- State the final register value.
memory[operand] and memory[effective address].
Practice
Core questions
- Explain the difference between immediate and direct addressing.
- Trace
LDI 301using the memory model on this page. - Calculate the effective address for
LDX 303when IX contains 4. - Calculate the effective address for
LDD [BR] + 8when BR contains 300. - Explain why indirect addressing can be described as following a pointer.
- Explain why indexed addressing is useful when accessing array elements.
- Explain how
LDD PRICEcan still use direct addressing.
New memory challenge
Use this separate memory state:
| Address | Content |
|---|---|
| 410 | 77 |
| 411 | 414 |
| 412 | 23 |
| 413 | 58 |
| 414 | 31 |
| 415 | 86 |
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 |
|---|---|
| Immediate | Operand = value |
| Direct | Operand = address of value |
| Indirect | Operand = address of pointer |
| Indexed | Effective address = operand + IX |
| Relative | Effective address = base + offset |