When an instruction needs to access data, it must specify WHERE that data is. Different addressing modes provide different ways to specify the location.
Immediate Addressing
ADD #5 // Add the literal value 5 to accumulator
LDA #100 // Load the literal value 100 into accumulator
The # symbol indicates immediate addressing. The value 5 or 100 is used directly.
Direct Addressing
ADD 50 // Add the value STORED AT address 50 to accumulator
LDA 100 // Load the value STORED AT address 100 into accumulator
If address 50 contains the value 7, then ADD 50 adds 7.
Indirect Addressing
| Memory address | Value stored |
|---|---|
| 50 | 75 |
| 75 | 42 |
LDA @50 // indirect addressing, @ symbol
1. Look at address 50 → find value 75
2. Use 75 as the actual address
3. Look at address 75 → find value 42
4. Load 42 into accumulator
Result: Accumulator = 42
Indexed Addressing
| Item | Value |
|---|---|
| Base address | 100 |
| Index register (X) | 3 |
| Effective address | 100 + 3 = 103 |
LDA 100,X
Action: Load value from address 103 into accumulator.
Why is this useful? Perfect for arrays - the base address is where the array starts, and the index moves through each element.| X value | Instruction | Address used | Value loaded |
|---|---|---|---|
| 0 | LDA 100,X | 100 | 10 |
| 1 | LDA 100,X | 101 | 20 |
| 2 | LDA 100,X | 102 | 30 |
Addressing Modes Summary
• Operand Contains: The actual value
• Example: ADD #5
• Use Case: Constants, fixed values
Direct
• Operand Contains: Address of data
• Example: ADD 50
• Use Case: Simple variables
Indirect
• Operand Contains: Address of address
• Example: ADD @50
• Use Case: Pointers, dynamic access
Indexed
• Operand Contains: Base + index
• Example: ADD 100,X
• Use Case: Arrays, tables
• Immediate = the value is RIGHT THERE in the instruction
• Direct = go DIRECTLY to that address for the value
• Indirect = indirect route - address gives you another address
• Indexed = base + index (like array access)