Worked solution from the Processor Fundamentals Paper 1 Theory Fundamentals booklet, Part 2 of 3.
LDX adds IX to the address, so IX = 0 reads address 110, IX = 1 reads 111 and IX = 2 reads 112. The loop stops when the value read equals 35. Blank cells mean no change.
| Instruction address | ACC | IX | 100 | 101 | 110 | 111 | 112 | Output |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 66 | 65 | 35 | ||||
| 77 | 0 | |||||||
| 78 | 66 | |||||||
| 79 | ||||||||
| 80 | ||||||||
| 81 | ||||||||
| 82 | 66 | |||||||
| 83 | 1 | |||||||
| 84 | ||||||||
| 85 | 1 | |||||||
| 86 | 1 | |||||||
| 87 | 65 | |||||||
| 88 | ||||||||
| 89 | ||||||||
| 81 | 66 | |||||||
| 82 | ||||||||
| 83 | 1 | |||||||
| 84 | 2 | |||||||
| 85 | 2 | |||||||
| 86 | 2 | |||||||
| 87 | 35 | |||||||
| 88 | ||||||||
| 89 | ||||||||
| 90 | 2 | |||||||
| 91 | 50 | |||||||
| 92 | 2 | |||||||
| 93 |
Rows 77 to 80 (IX = 0, ACC = 66, no jump) [1]
Rows 81 to 88, first loop (101 = 66, ACC = 1, 100 = 1, IX = 1, ACC = 65) [1]
Row 89 (jump back to 81) and rows 81 to 88 on the second loop (ACC = 66, 1, then 2, 100 = 2, IX = 2, ACC = 35, compare True) [1]
Rows 89 to 93 (no jump, ACC = 2, then 50, output 2, END) [1]
The three pairs of instructions use address 165 as a temporary store.
It swaps the contents of memory addresses 100 and 101 [1]
XOR flips the bits where the operand has 1: 10010011 XOR 00011111.
10001100 [1]
AND keeps the bits where the operand has 1: 10010011 AND 11110000.
10010000 [1]
OR sets the bits where the operand has 1: 10010011 OR 11001100.
11011111 [1]
Shift right 2 places and fill the left with zeros: 10010011 → 00100100.
00100100 [1]
| Task | First pass | Second pass |
|---|---|---|
| Remove comments. | ✓ | |
| Read the assembly language program one line at a time. | ✓ | ✓ |
| Generate the object code. | ✓ | |
| Check the opcode is in the instruction set. | ✓ |
Remove comments (first pass) and read one line at a time (both passes) correct [1]
Generate the object code (second pass) and check the opcode (first pass) correct [1]
▶ Whole paper
Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.