The same operand, 200, can mean the number 200, the value stored at address 200, or something stored somewhere else entirely. The addressing mode decides which. Learn the five modes in the 9618 syllabus and work out exactly what each instruction loads.
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.
Fig. 1: one operand, 200, gives four different values in four different modes
Section 01
Five modes.
In the lab, choose a mode, change the operand and the index register, and watch which memory location is used. Then fix each definition in your memory with its 9618 instruction.
Mode
How the operand is used
9618 example
Immediate
The operand is the actual value to use.
LDM #200 loads the number 200
Direct
The operand is the address of the value.
LDD 200 loads the contents of address 200
Indirect
The operand is an address; the contents of that address is the address of the value.
LDI 200 loads the contents of the address stored in 200
Indexed
The address is the operand + the contents of the index register (IX).
LDX 200 with IX = 2 loads the contents of 202
Relative
The address is an offset from the address of the current instruction.
An instruction at 150 with offset 6 uses address 156
Examiner trap
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".
Section 02
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. Draw an arrow for every step you follow.
Address
200
201
202
203
204
Contents
203
50
7
18
25
The index register (IX) holds 2.
Worked example Four loads
Using the memory above, give the contents of the ACC after each instruction: LDM #200, LDD 200, LDX 200, LDI 200.
LDM #200 is immediate: the operand is the value, so ACC = 200.
LDD 200 is direct: load the contents of address 200, so ACC = 203.
LDX 200 is indexed: address = 200 + IX = 200 + 2 = 202, which holds 7, so ACC = 7.
LDI 200 is indirect: address 200 holds 203, so use address 203, which holds 18, so ACC = 18.
Answer: 200, 203, 7, 18
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.
LDX 202: address 202 + 1 = 203, so ACC = 18. CMI 200: address 200 holds 203, and 203 holds 18; the ACC holds 18, so the compare is True and JPE would jump.
Examiner trap
Indexed and indirect are easy to swap. Indexed adds IX to the operand; indirect looks up a second address in memory.
Stage 1 · Learn
Check what the sim just showed you
Four quick checks. Each correct answer earns XP and records this skill on your profile.
Quick check+10 XP
In which mode is the operand the actual value to be used?
Quick check+10 XP
In the lab, IX holds 3. Which address does LDX 210 use?
Quick check+10 XP
Address 200 holds 203 and address 203 holds 18. What does LDI 200 load?
Quick check+10 XP
Which mode works out the address as an offset from the current instruction?
Section 03
Why each mode exists.
Questions also ask why a mode is useful. Link each mode to the job it makes easy.
Immediate: fast, because no memory access is needed for the data; used for constants such as a starting value or a counter limit.
Direct: simple access to a variable stored at a fixed address.
Indirect: the stored address can be changed while the program runs, so one instruction can reach different locations (like a pointer); it can also reach addresses too large to fit in the operand.
Indexed: steps through an array or a list: keep the base address in the operand and increase IX by 1 each time round a loop.
Relative: the program can be loaded anywhere in memory and still work (relocatable code), because addresses are worked out from the current instruction rather than fixed.
100 LDR #0
101 LDX 300
102 OUT
103 INC IX
104 ...
LDR #0 sets IX to 0; LDX 300 loads the contents of 300 + IX; INC IX moves on to the next element, so the next time round the loop LDX 300 reads 301, then 302, and so on.
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.
With indexed addressing the same instruction is reused: increasing IX by 1 each time round the loop moves to the next element, so the code is shorter and works for a list of any length.
Stage 2 · Exam
Exam-style questions
Unlocks once the four checks above are done. Worth more XP, written to AS Paper 1 and Paper 2 standard.
Finish the four checks above to unlock the exam questions
Exam style+20 XP
Address 80 holds 85, address 85 holds 4 and IX holds 5. Which instruction loads 4 into the ACC?
Exam style+20 XP
Which instruction uses immediate addressing?
Exam style+20 XP
Why is indexed addressing useful?
Exam style+20 XP
Which is an advantage of relative addressing?
Skill unlocked
Addressing modes, mastered.
This skill is now recorded on your profile. Keep the chain going.