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

4.2.2 Addressing Modes: Immediate, Direct and Indirect

πŸ”’ Lesson slides are available to signed-in users. Sign in

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.

TermMeaningQuestion to ask
OperandThe information written after the opcode.What information does the instruction provide?
AddressA number that identifies a memory location.Which location should be accessed?
ContentsThe 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.
Ask: β€œIs the operand the value itself?” If yes, the instruction uses immediate addressing.

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.

AddressContents stored there
246581
58193
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.

  1. The operand 246 identifies the first memory location.
  2. That location contains 581, which is an address, not the final data value.
  3. Memory location 581 contains 93; 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.

InstructionMeaning of operandMemory lookups for the dataValue loaded into ACC
LDM #246The data value itselfNone246
LDD 246Address where the data is storedRead location 246581
LDI 246Address of a location containing the data addressRead location 246, then location 58193
Reliable method: name the addressing mode β†’ say what the operand represents β†’ follow the memory table β†’ state the final value in ACC.

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.

ADDRESSING MODE WALKTHROUGH

Choose an addressing mode

Ready

Memory table

AddressContents
246581
58193

Instruction and register

Choose a mode below.

ACCβ€”
Operand246
First locationβ€”
Next locationβ€”
Final valueACC

Interpret the operand

Choose a mode to see how the processor finds the value.

An address identifies a location. The contents are the value stored at that location.

6. Avoid these common mix-ups

Mix-upCorrect distinction
Immediate operand mistaken for an addressImmediate addressing uses the operand itself as the data value.
Direct operand mistaken for the dataIn direct addressing, the operand is an address. ACC receives the contents at that address.
Indirect intermediate address mistaken for the final valueIndirect addressing uses the first memory contents as a second address, then reads the data there.
Address and contents treated as the same thingAn address identifies a location; contents are the value stored in that location.

7. Check your understanding

Try each question before opening the suggested response.

  1. 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.

  2. Memory address 246 contains 581. What does LDD 246 load into ACC?
    Suggested response

    It loads 581. Direct addressing uses 246 as the address and loads the contents stored there.

  3. Address 246 contains 581, and address 581 contains 93. What does LDI 246 load into ACC?
    Suggested response

    It loads 93. The processor uses 246 to obtain the next address, 581, then reads the contents at 581.

  4. Explain why LDD 246 and LDI 246 produce 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.

  5. 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.