Addressing modes — AQA A-Level Computer Science
Addressing modes dictate how the operand field of a machine-code instruction identifies the data to be used, whether as a literal constant, memory address, or offset. In AQA A-Level Computer Science, mastering immediate, direct, indirect, and indexed addressing is essential for assembly language comprehension and understanding processor architecture.
Addressing modes explained
This statement requires you to understand two addressing modes and to apply them to work out what an instruction does.
Read the full explanation
In immediate addressing, the operand is the actual data value to be used, so the instruction contains the value itself. In direct addressing, the operand is the memory address where the data is stored, so the processor must fetch the value from that location. Applying the modes means reading an instruction, deciding which mode it uses from the form of its operand, and then tracing the result. For example, if the operand 20 is used immediately, the value 20 is used directly; if it is used directly, the processor reads the contents of memory address 20 and uses that value instead. Always state clearly whether the operand is a value or an address before carrying out the calculation.
Your focus
- Understand and apply immediate and direct addressing modes.
Which command word is this?
State the operational mechanics of the addressing mode clearly, detailing how the processor locates the operand without needing evaluation.
Addressing modes exam tips
Topic Overview
Addressing modes define the rules used by the central processing unit to interpret the operand field within machine-code instructions. Understanding these modes reveals how low-level programs manipulate literals, access variables in main memory, and traverse structured datasets efficiently.
In the AQA A-Level specification, students must distinguish between immediate, direct, indirect, and indexed addressing modes. Mastery of this topic connects low-level Fetch-Execute mechanics with high-level programming constructs such as arrays, pointers, and dynamic memory allocation.
Key Concepts
- →Immediate Addressing: The operand field contains the actual data value to be used by the instruction, requiring no memory access.
- →Direct (Absolute) Addressing: The operand field contains the memory address where the target data is held, requiring one memory read.
- →Indirect Addressing: The operand field contains the memory address of a location that holds the target effective address, requiring two memory reads.
- →Indexed Addressing: The effective address is calculated dynamically at runtime by adding a constant base address to the contents of the Index Register (IX).
Marking Points
- Defines immediate addressing as the operand being the data value itself.
- Defines direct addressing as the operand being the memory address where the data is held.
- Applies immediate addressing by using the operand value directly in the calculation.
- Applies direct addressing by fetching the contents of the stated memory address.
- Distinguishes the two modes by whether the operand is treated as a value or an address.
Examiner Tips
- 💡Identify the mode first by asking whether the operand is a value or an address, then carry out the calculation.
- 💡Show the memory lookup step explicitly in direct addressing questions.
- 💡Use the terms immediate and direct consistently with the definitions in the specification.
- 💡Look out for assembly prefix conventions: '#' almost always denotes immediate addressing, whereas parentheses or brackets such as '(100)' denote indirect addressing in AQA exam papers.
- 💡When explaining indexed addressing, always write out the formula 'Effective Address = Base Address + Index Register' to guarantee marks.
- 💡In scenario questions involving arrays, always recommend indexed addressing and explain that incrementing the Index Register allows sequential element access in a loop.
Common Mistakes
- Treats the operand as a memory address in immediate addressing; correct by using the operand as the data value itself.
- Uses the operand value in direct addressing without reading the memory location; correct by fetching the contents of that address.
- Confuses direct addressing with indirect addressing; correct by noting direct addressing uses the operand as the address itself.
- Believing immediate addressing uses memory: Students often write that immediate addressing looks up address 0 or a register, rather than using the literal value provided within the instruction itself.
- Confusing indirect addressing with indexed addressing: Students often mix up looking up a pointer (indirect) with adding an offset via the Index Register (indexed).
- Overlooking the performance penalty of indirect addressing: Students frequently forget that indirect addressing incurs an extra memory read cycle, degrading execution speed relative to direct addressing.
Revision Plan
- 1Day 1: Define all four addressing modes (immediate, direct, indirect, indexed) and sketch memory lookup diagrams for each.
- 2Day 2: Complete trace tables and memory lookup questions calculating the accumulator value for identical operand numbers across different modes.
- 3Day 3: Practice AQA past paper questions focusing on the benefits and trade-offs of indirect versus direct addressing.
- 4Day 4: Implement a mock assembly loop traversing an array using indexed addressing and an increment instruction on the Index Register.
Exam Question Types
- 📋Trace and Calculate: Given a memory map and a series of instructions using various addressing modes, calculate the values loaded into registers.
- 📋Definitions and Comparisons: Short-answer questions asking for concise definitions of specific modes and comparisons between their execution speed and memory limits.
- 📋Application Scenarios: Explaining which addressing mode is most appropriate for a given task (e.g. declaring a mathematical constant vs. iterating over an array).
Command Word Expectations (AQA)
State the operational mechanics of the addressing mode clearly, detailing how the processor locates the operand without needing evaluation.
Provide technical reasoning, such as why a particular mode is selected for an array or the performance impact of multi-stage memory lookups.
Identify explicit similarities and differences between two modes, addressing factors like memory access cycles, execution speed, and addressable range.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A computer uses a 16-bit instruction format. Memory location 200 contains the value 450. Memory location 450 contains the value 88. The Index Register (IX) currently stores the denary value 5. Determine the value loaded into the accumulator (ACC) by each of the following assembly instructions: (a) LOAD #200 (b) LOAD 200 (c) LOAD (200) (d) LOAD 200, IX
- 1.Step 1: Identify the addressing mode indicated by the syntax for each instruction: # denotes immediate, a bare number denotes direct, brackets denote indirect, and IX denotes indexed.
- 2.Step 2: For (a) LOAD #200 (Immediate): The operand itself is the data value, so 200 is loaded directly into ACC.
- 3.Step 3: For (b) LOAD 200 (Direct): The operand 200 is the memory address; look up location 200, which holds 450. Thus, 450 is loaded into ACC.
- 4.Step 4: For (c) LOAD (200) (Indirect): Location 200 holds 450, which is treated as an address. Look up location 450, which holds 88. Thus, 88 is loaded into ACC.
- 5.Step 5: For (d) LOAD 200, IX (Indexed): Calculate effective address by adding base address 200 to IX (5), giving 205. If location 205 is uninitialized or not stated, show the formula. Assuming location 205 contains its own look-up, state: Effective Address is 205, value loaded is contents of memory location 205.
Question: Explain one advantage and one disadvantage of using indirect addressing compared to direct addressing in assembly programming.
- 1.Step 1: Identify the structural constraints of direct addressing (limited address space determined by the bit-width of the operand field).
- 2.Step 2: Contrast this with indirect addressing, noting that the location pointed to can utilize the full word length of memory, allowing access to a larger address space.
- 3.Step 3: Consider the operational overhead, specifically the extra Fetch-Execute cycle needed to retrieve the effective address before fetching the operand.