Immediate, Direct and Indirect Addressing
An addressing mode tells the processor how to interpret an instruction's operand and where to obtain the value used by the instruction. The same operand can lead to different values in the ACC because each mode interprets it differently.
By the end of this page, you should be able to:
- describe immediate, direct and indirect addressing;
- use a memory table to find the value loaded into ACC;
- distinguish an address from the contents stored at that address;
- explain why the same operand can produce different results in different modes.
1. Keep address, value and contents separate
A memory address identifies a location. The contents are the value stored at that location. They are related, but they are not the same thing.
| Term | Meaning | Question to ask |
|---|---|---|
| Operand | The information written after the opcode. | What information does the instruction provide? |
| Address | A number that identifies a memory location. | Which location should be accessed? |
| Contents | The value stored at a memory location. | What value is found at that location? |
An address is not the data stored there
If an instruction uses an address to access memory, do not automatically put that address into ACC. Check the addressing mode and follow the memory contents as required.
2. Immediate addressing uses the operand itself
With immediate addressing, the operand is the data value. The instruction uses that value directly; it does not use the operand to look up a data value in memory.
LDM #246 Β β Β the value 246 is loaded into ACC
- The
#symbol indicates an immediate value in this instruction set. - The operand itself is the value used by the instruction.
- No memory lookup is needed to obtain this data value.
3. Direct addressing uses the operand as an address
With direct addressing, the operand identifies the memory location where the data is stored. The processor reads the contents at that location and loads that value into ACC.
| Address | Contents stored there |
|---|---|
| 246 | 581 |
| 581 | 93 |
LDD 246 uses 246 as the address. Memory location 246 contains
581, so 581 is loaded into ACC.
The operand is the address; ACC receives the contents found at that address. Do not confuse the location with the value stored there.
4. Indirect addressing follows an address stored in memory
With indirect addressing, the operand identifies a memory location that contains the address of the data. The processor first reads this address, then accesses that second location to obtain the data value.
- The operand
246identifies the first memory location. - That location contains
581, which is an address, not the final data value. - Memory location
581contains93; that value is loaded into ACC.
LDI 246 follows the address stored at location 246 and then reads the data at
the resulting location. ACC receives 93.
Do not stop at the intermediate address
In this example, 581 tells the processor where to look next. It is not the final value
loaded into ACC. The final value is the contents found at that second location.
5. Compare the three modes
Use the same operand and memory contents, but apply a different rule for interpreting the operand.
| Instruction | Meaning of operand | Memory lookups for the data | Value loaded into ACC |
|---|---|---|---|
LDM #246 | The data value itself | None | 246 |
LDD 246 | Address where the data is stored | Read location 246 | 581 |
LDI 246 | Address of a location containing the data address | Read location 246, then location 581 | 93 |
Interactive: follow the operand
The table contains the same values used in the worked explanation above. Select an addressing mode and
step through the processor's interpretation of operand 246. Watch how the value in ACC changes.
6. Avoid these common mix-ups
| Mix-up | Correct distinction |
|---|---|
| Immediate operand mistaken for an address | Immediate addressing uses the operand itself as the data value. |
| Direct operand mistaken for the data | In direct addressing, the operand is an address. ACC receives the contents at that address. |
| Indirect intermediate address mistaken for the final value | Indirect addressing uses the first memory contents as a second address, then reads the data there. |
| Address and contents treated as the same thing | An address identifies a location; contents are the value stored in that location. |
7. Check your understanding
Try each question before opening the suggested response.
-
What does the operand represent in immediate addressing?
Suggested response
The data value itself. The processor does not use that operand to look up a data value in memory.
-
Memory address
246contains581. What doesLDD 246load into ACC?Suggested response
It loads
581. Direct addressing uses246as the address and loads the contents stored there. -
Address
246contains581, and address581contains93. What doesLDI 246load into ACC?Suggested response
It loads
93. The processor uses246to obtain the next address,581, then reads the contents at581. -
Explain why
LDD 246andLDI 246produce different values for the same memory table.Suggested response
Direct addressing loads the contents at location
246. Indirect addressing treats those contents as another address and loads the contents found at that second location. -
Which addressing mode uses the operand itself as the data value?
Suggested response
Immediate addressing.
Final check
For an indirect-addressing explanation, describe both lookups. State the intermediate address and the final data value separately so that the marker can see the full sequence.