Study Guide

Addressing Modes

Computer ScienceΒ· Unit 4: Processor FundamentalsΒ· 45 min read

1. Immediate and Direct Addressingβ˜…β˜…β˜†β˜†β˜†β± 10 min

πŸ“˜ Definition

Addressing Mode

A rule that specifies how the CPU calculates the effective memory address of the target data or instruction from the address field of an assembly instruction.

πŸ“˜ Definition

Immediate Addressing

The value to be used by the instruction is stored directly in the instruction itself. No extra memory access is required to retrieve the operand.

Example:

Used to load constant values into registers.

πŸ“ Worked Example

Add the immediate value 15 to register R0. State what is stored in the instruction's address field and whether any extra memory access is needed.

  1. 1
    1. In immediate addressing, the operand is the value itself, stored directly in the address field.
  2. 2
    1. No extra memory access is needed after fetching the instruction, because the value is already embedded in the instruction.
  3. 3

    Result: The address field holds 15, and 0 extra memory accesses are required.

πŸ“˜ Definition

Direct Addressing

The address field of the instruction stores the full effective memory address of the target data. The CPU fetches the data directly from this address in one extra memory cycle.

Example:

Used to access single fixed memory variables.

πŸ“ Worked Example

Load the value stored at memory address 1000 into register R1. What value is stored in the instruction's address field?

  1. 1
    1. In direct addressing, the address field equals the effective address of the target data.
  2. 2
    1. The target data is at address 1000, so the address field stores exactly 1000.
  3. 3

    Result: Address field value = 1000, 1 extra memory access to retrieve the data.

2. Indirect Addressingβ˜…β˜…β˜…β˜†β˜†β± 12 min

πŸ“˜ Definition

Indirect Addressing

The address field of the instruction stores the address of a memory location (or register) that holds the full effective address of the target data. Requires multiple memory accesses to retrieve the data.

Example:

Used for pointers, dynamic data, and accessing large memory spaces.

πŸ“ Worked Example

An instruction uses memory indirect addressing, with an address field value of 2000. Memory location 2000 stores 5000. What is the effective address of the target data, and how many memory accesses are needed?

  1. 1
    1. After fetching the instruction, the CPU first reads the address field value 2000.
  2. 2
    1. First extra memory access: retrieve the effective address stored at 2000, which is 5000.
  3. 3
    1. Second extra memory access: retrieve the target data from the effective address 5000.
  4. 4

    Result: Effective address = 5000, 2 extra memory accesses.

3. Indexed Addressingβ˜…β˜…β˜…β˜…β˜†β± 15 min

πŸ“˜ Definition

Indexed Addressing

The effective address is calculated by adding a constant base offset (stored in the instruction) to the value held in a dedicated index register.

Example:

The most efficient mode for accessing elements of an array.

πŸ“ Worked Example

An array starts at base address 200. Access the 3rd element (0-indexed, index = 2). Index register X holds 2. Calculate the effective address.

  1. 1
    1. The formula for effective address in indexed addressing is:
  2. 2
    EA=Base Offset+Index Register ValueEA = \text{Base Offset} + \text{Index Register Value}
  3. 3
    1. Substitute the given values: Base Offset = 200, Index Register Value = 2.
  4. 4
    1. Calculate: .
  5. 5

    Result: The effective address of the 3rd array element is 202.

4. Relative Addressingβ˜…β˜…β˜…β˜†β˜†β± 12 min

πŸ“˜ Definition

Relative Addressing

The effective address is calculated by adding an offset value (stored in the instruction) to the current value of the Program Counter (PC).

Example:

Used for branching and jumping to nearby instructions.

πŸ“ Worked Example

The current branch instruction is stored at address 100, and is 4 bytes long. After fetching the instruction, the PC holds 104. The branch offset is +12. Calculate the effective address of the branch target.

  1. 1
    1. The formula for effective address in relative addressing is:
  2. 2
    EA=PC+OffsetEA = PC + \text{Offset}
  3. 3
    1. Recall that after fetching an instruction, the PC is automatically updated to point to the next instruction, so we use this updated PC value.
  4. 4
    1. Substitute values: .
  5. 5

    Result: The branch target is at effective address 116.

5. Common Pitfalls

Wrong move:

Confusing immediate and direct addressing, assuming the value in the address field is always an address.

Why:

Immediate addressing uses the address field value as the actual operand, not an address.

Correct move:

Check if the instruction needs a constant value (immediate) or data from memory (direct).

Wrong move:

Using the address of the current instruction for relative addressing calculations.

Why:

The PC is updated to point to the next instruction before calculating the effective address, so this gives the wrong offset.

Correct move:

Always add the offset to the updated PC value (current instruction address + instruction length).

Wrong move:

Claiming memory indirect addressing only needs one extra memory access.

Why:

One access is needed to retrieve the effective address, a second to retrieve the actual data.

Correct move:

Count 2 extra memory accesses for memory indirect addressing, 1 for register indirect.

Wrong move:

Using the index value as the full effective address for array access with indexed addressing.

Why:

Students forget to add the array's base address stored as the instruction offset.

Correct move:

Always add the base offset of the array to the index register value to get the effective address.

Wrong move:

Claiming immediate addressing requires an extra memory access to get the operand.

Why:

The operand is embedded directly in the instruction itself, so no extra access is needed.

Correct move:

Immediate addressing requires 0 extra memory accesses after fetching the instruction.

6. Quick Reference Cheatsheet

Addressing Mode

Effective Address

Extra Memory Accesses

Common Use Case

Immediate

Value stored in instruction

0

Loading constants

Direct

EA = Address field value

1

Accessing fixed variables

Memory Indirect

EA = Value at (Address field)

2

Accessing pointers/dynamic data

Indexed

EA = Base offset + Index register

1

Accessing array elements

Relative

EA = Updated PC + Offset

0

Branching/jumps

When this came up on past exams

AI-estimated based on syllabus patterns β€” cross-check with official past papers for accuracy. Use only as revision-focus signals.

  • 2022 Β· 42

    Identify common addressing modes

  • 2023 Β· 41

    Calculate effective addresses

  • 2021 Β· 43

    Compare addressing mode use cases

Going deeper

What's Next

Addressing modes are a core component of CPU instruction set design, and understanding them is key to interpreting assembly instructions, explaining CPU memory access behaviour, and answering common exam questions on processor fundamentals for CIE 9618. This topic builds on your existing knowledge of instruction formats and memory organisation, and forms the foundation for working with assembly programming and understanding how the CPU interacts with memory during instruction execution. Addressing mode questions appear regularly in both multiple-choice and extended response sections of Paper 4, so mastering effective address calculations for each mode is critical for exam success.