Show understanding of and be able to use different modes of addressing
4.2 Assembly Language – Addressing Modes
Think of an addressing mode as the *route* your CPU takes to find the data it needs. Just like you might look for a book by its title, author, shelf number, or by asking a librarian, the CPU can fetch data in several ways. Below we explore the most common modes and show how to use them in simple assembly snippets. 📚
| Mode | What It Does | Example Syntax |
|---|---|---|
| Immediate | Uses a constant value directly in the instruction. | MOV R1, #10 |
| Register | Data is already in a CPU register. | ADD R1, R2 |
| Direct | Uses a memory address that is known at compile‑time. | LOAD R1, 0x2000 |
| Indirect | The address is stored in a register. | LOAD R1, (R2) |
| Indexed | Adds a constant offset to a base register. | LOAD R1, 4(R2) |
| Base+Offset | Adds two registers together to form an address. | LOAD R1, (R2+R3) |
Immediate Mode – “I’ve got the number right here!”
📌 Use case: When you need to load a constant value into a register.
Analogy: Imagine you’re handing a friend a specific number written on a card – no searching required.
Example:
- Write the constant after a hash:
MOV R1, #15 - CPU puts 15 directly into register R1.
- Exam tip: Look for the
#symbol – that’s a giveaway for immediate mode.
Register Mode – “It’s already in the pocket!”
📌 Use case: When the data you need is already stored in a register.
Analogy: You have a phone number saved in your phone’s contacts – you just dial it.
Example:
- Assume R2 holds the value 7.
- Execute
ADD R1, R2to add 7 to whatever is in R1.
- Exam tip: No brackets or numbers – just register names.
Direct Mode – “I know the exact address!”
📌 Use case: When the memory location is fixed and known at compile time.
Analogy: You have a library card that tells you the exact shelf and book number.
Example:
- Memory address 0x3000 holds the number 42.
- Execute
LOAD R1, 0x3000to fetch it.
- Exam tip: Look for a hexadecimal number (0x…) in the instruction.
Indirect Mode – “The address is hidden in a register.”
📌 Use case: When the address of the data is stored in a register, often used for pointers.
Analogy: You give your friend a map (the register) that points to the treasure (the data).
Example:
- R2 contains the address 0x4000.
- Execute
LOAD R1, (R2)to read the value at that address.
- Exam tip: Parentheses around a register indicate indirect mode.
Indexed Mode – “Add a small offset.”
📌 Use case: Accessing array elements where the base address is in a register and the offset is a constant.
Analogy: You know the library section (base register) and you need the 5th book in that section (offset).
Example:
- R2 holds the start of an array at 0x5000.
- Execute
LOAD R1, 8(R2)to fetch the value 8 bytes past the start.
- Exam tip: The number before the parentheses is the offset.
Base+Offset Mode – “Add two registers.”
📌 Use case: Combining two registers to form a dynamic address, common in pointer arithmetic.
Analogy: You have a base address (like a street number) and a variable offset (like a house number) that together give you the exact location.
Example:
- R2 = 0x6000 (base), R3 = 0x0010 (offset).
- Execute
LOAD R1, (R2+R3)to read from 0x6010.
- Exam tip: Look for a plus sign inside parentheses.
Quick Reference Cheat‑Sheet
Mode | Syntax | When to Use
Immediate | MOV R1, #5 | Constants
Register | ADD R1, R2 | Data already in registers
Direct | LOAD R1, 0x2000 | Fixed memory address
Indirect | LOAD R1, (R2) | Pointer stored in register
Indexed | LOAD R1, 4(R2) | Array indexing with constant offset
Base+Offset | LOAD R1, (R2+R3) | Dynamic address from two registers
Exam Tips & Tricks
- 🧩 Identify the mode quickly: Symbols like
#, parentheses, or a plus sign are your clues. - 🔍 Check the operand type: Numbers → direct or immediate; register names → register or indirect.
- 📚 Practice with real code: Write a small routine that uses at least three different modes.
- 📝 Remember the syntax: For indirect and indexed modes, the address is always inside parentheses.
Revision
Log in to practice.