Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q21 · 9618/11/O/N/22 Q6

Worked solution from the Processor Fundamentals Paper 1 Theory Fundamentals booklet, Part 2 of 3.

Q219618/11/O/N/22original Q6Structured · 11 marks
Question 6 from 9618/11/O/N/22

Worked solution

(a)(i)

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 addressACCIX100101110111112Output
00666535
770
7866
79
80
81
8266
831
84
851
861
8765
88
89
8166
82
831
842
852
862
8735
88
89
902
9150
922
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]

(a)(ii)

The three pairs of instructions use address 165 as a temporary store.

It swaps the contents of memory addresses 100 and 101 [1]

(b)(i)

XOR flips the bits where the operand has 1: 10010011 XOR 00011111.

10001100 [1]

(b)(ii)

AND keeps the bits where the operand has 1: 10010011 AND 11110000.

10010000 [1]

(b)(iii)

OR sets the bits where the operand has 1: 10010011 OR 11001100.

11011111 [1]

(b)(iv)

Shift right 2 places and fill the left with zeros: 10010011 → 00100100.

00100100 [1]

(c)

TaskFirst passSecond 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]

KEY IDEAIndexed addressing reads address + IX, and a trace table only changes the cell that each instruction changes.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/11/O/N/22 question 6
VIDEO
▶ 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.