Teachers' Portal  /  A-Level Computer Science 9618  /  Processor fundamentals  /  Addressing modes
Lesson pack · A-Level Computer Science 9618 · 4.2 · AS Level

Addressing modes

Where is the value? The same operand, 200, can mean the number 200, the value stored at address 200, or something stored somewhere else entirely.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Processor fundamentals
Syllabus reference
Cambridge International AS and A Level Computer Science 9618, 4.2
Level
AS Level
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 6 of 8 in Processor fundamentals; follows Assembly language and the two-pass assembler; leads into Tracing an assembly language program
Central model
Fig. 1: one operand, 200, gives four different values in four different modes
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • Five modes: In the lab, choose a mode, change the operand and the index register, and watch which memory location is used.
  • Work out the value: The usual exam question gives a block of memory, a value in IX and several instructions, and asks what ends up in the accumulator.
  • Why each mode exists: Questions also ask why a mode is useful.
Key points to leave on the board
  • Immediate (#): the operand is the value.
  • Direct: go to the address once.
  • Indirect: go to the address, read another address, go there.
  • Indexed: add IX to the operand first. Relative: offset from the current instruction.
The core visual model

One picture every idea returns to

An addressing mode tells the processor how to use the operand to find the data. Immediate: the operand is the value (LDM #n). Direct: the operand is the address of the value (LDD). Indirect: the operand is an address that holds the address of the value (LDI, CMI). Indexed: the address is the operand plus the contents of the index register (LDX). Relative: the address is an offset number of locations away from the address of the current instruction.

same operand, different modes (IX holds 2) 200 | 203 201 | 50 202 | 7 203 | 18 204 | 25 LDM #200ACC = 200 LDD 200ACC = 203 LDX 200ACC = 7 LDI 200ACC = 18 immediate: the operand is the valuedirect: the operand is the address indexed: 200 + IX = 202indirect: 200 holds 203, use 203
Fig. 1: one operand, 200, gives four different values in four different modes
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Where is the value?. The same operand, 200, can mean the number 200, the value stored at address 200, or something stored somewhere else entirely. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: Five modesIn the lab, choose a mode, change the operand and the index register, and watch which memory location is used. Project tab 6 of the lab (Addressing modes) and let a student drive it while the class predicts.Whole class, then pairs
13 to 21 minTeach and check: Work out the valueThe usual exam question gives a block of memory, a value in IX and several instructions, and asks what ends up in the accumulator. Model the worked example Four loads on the board, one line at a time. Your turn: Using the same memory, but with IX now holding 1, give the ACC after LDX 202, and state whether CMI 200 followed by JPE would jump if the ACC held 18.Pairs
21 to 30 minTeach and check: Why each mode existsQuestions also ask why a mode is useful. Your turn: A list of five characters is stored at addresses 300 to 304. Explain why LDX 300 inside a loop is better than writing LDD 300, LDD 301, LDD 302 and so on.Mix-Pair-Share
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 15 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Why each mode exists, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Mix-Pair-Share

Students mix around the room until you call pair; they pair with the nearest classmate, discuss the prompt, then mix again. Three prompts of rising difficulty, three different partners.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
The # is what makes LDM, LDR, ADD #n, SUB #n and CMP #n immediate.Without it, ADD 5 means "add the contents of address 5", not "add 5".
Indexed and indirect are easy to swap.Indexed adds IX to the operand; indirect looks up a second address in memory.
Worksheet

Addressing modes: worksheet

6 questions, 15 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · recall[3 marks]

Describe immediate, direct and indexed addressing.

Q2 · trace[4 marks]

The index register holds 3. Memory holds:

Address500501502503504
Contents50295001431

Give the contents of the ACC after each instruction is executed: (a) LDD 502, (b) LDI 502, (c) LDX 501, (d) LDM #502.

Q3 · explain[2 marks]

Explain the difference between indirect addressing and indexed addressing.

Q4 · apply[2 marks]

Using the memory in question 2, with IX holding 3, the ACC holds 500. State whether the compare in each instruction is True or False: (a) CMI 500, (b) CMP 503.

Q5 · explain[2 marks]

Explain why relative addressing allows a program to be relocated in memory.

Q6 · analysis[2 marks]

A programmer wants to add 10 to the accumulator but writes ADD 10. Explain the error and correct it.

Answer key and marking notes
Q1 · 3 marks
  • Immediate: the operand is the value to be used.
  • Direct: the operand is the address that holds the value.
  • Indexed: the address used is the operand plus the contents of the index register.
Q2 · 4 marks
  • (a) 500 (the contents of 502).
  • (b) 502 (502 holds 500; 500 holds 502).
  • (c) 31 (501 + 3 = 504, which holds 31).
  • (d) 502 (the value itself).
Q3 · 2 marks
  • Indirect: the operand is the address of a location that holds the address of the data.
  • Indexed: the address of the data is found by adding the contents of the index register to the operand.
Q4 · 2 marks
  • (a) 500 holds 502; 502 holds 500; the ACC is 500, so True.
  • (b) 503 holds 14; the ACC is 500, so False.
Q5 · 2 marks
  • Each address is given as an offset from the address of the current instruction.
  • So if the whole program is moved, the offsets still point to the correct locations (no addresses need changing).
Q6 · 2 marks
  • ADD 10 uses direct addressing: it adds the contents of address 10.
  • It should be ADD #10 (immediate addressing) to add the number 10.
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

An instruction stored at address 250 uses relative addressing with an offset of 7. Which address does it use?

  • A257
  • B243
  • C7
  • DThe address stored at location 7
Q21 mark

Memory holds the values below.

Address400401402403404
Contents40312400279

The index register (IX) holds 2.

What does the accumulator hold after LDD 402?

  • A400
  • B403
  • C9
  • D402
Q31 mark

Memory holds the values below.

Address400401402403404
Contents40312400279

The index register (IX) holds 2.

What does the accumulator hold after LDI 400?

  • A27
  • B403
  • C400
  • D402
Q41 mark

In which addressing mode is no further memory access needed to obtain the data once the instruction is in the CIR?

  • AImmediate
  • BDirect
  • CIndexed
  • DIndirect
Q51 mark

Memory holds the values below.

Address400401402403404
Contents40312400279

The index register (IX) holds 2.

The instructions LDX 401 then CMI 400 are executed. Which statement is correct?

  • AThe ACC holds 27 and the compare is True
  • BThe ACC holds 27 and the compare is False
  • CThe ACC holds 403 and the compare is True
  • DThe ACC holds 12 and the compare is False
Q61 mark

Memory holds the values below.

Address400401402403404
Contents40312400279

The index register (IX) holds 2.

Which instruction loads the value 9 into the accumulator?

  • ALDX 402
  • BLDI 402
  • CLDD 402
  • DLDM #404
Quiz key
Q1: A

Relative addressing adds the offset to the address of the current instruction: 250 + 7 = 257. 243 subtracts the offset instead of adding it. Using 7 itself treats the offset as a direct address, and following the address stored at 7 describes indirect addressing.

Q2: A

LDD is direct: it loads the contents of address 402, which is 400. 403 is what LDI 402 would give (402 holds 400, which holds 403). 9 is the result of LDX 402 (402 + 2 = 404), and 402 is the operand itself, as LDM #402 would load.

Q3: A

LDI 400 is indirect: address 400 holds 403, so the address to use is 403, which holds 27. 403 stops after the first visit, which is direct addressing (LDD 400). 400 is what indexed addressing gives (400 + 2 = 402, which holds 400), and 402 is just the indexed address, not its contents.

Q4: A

With immediate addressing (shown by #) the operand is the value, so it is already in the CIR. Direct addressing needs one memory read, indexed addressing also reads memory (after adding IX to the operand), and indirect addressing needs two memory reads.

Q5: A

LDX 401 uses 401 + 2 = 403, which holds 27, so ACC = 27. CMI 400 is indirect: 400 holds 403, and 403 holds 27, so 27 is compared with 27: True. Saying False compares the ACC with 403 (the address) instead of its contents. ACC 403 treats 403 as the value rather than the address, and ACC 12 forgets to add IX.

Q6: A

LDX 402 forms the address 402 + 2 = 404, which holds 9. LDI 402 follows 402 to 400 and loads its contents, 403. LDD 402 loads 400. LDM #404 is immediate, so it loads the number 404, not the contents of address 404.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonAssembly language and the two-pass assembler