Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q31 · 9618/11/M/J/25 Q8

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

Q319618/11/M/J/25original Q8Structured · 7 marks
Question 8 from 9618/11/M/J/25

Worked solution

(a)

Run the program from address 200, noting any change after each instruction (only changes are written).

LDD 81 loads 8. INC ACC makes 9. STO 83 stores 9 at address 83. LDI 82: address 82 holds 80, so load the contents of address 80, which is 10. CMP 83 compares 10 with 9: not equal, so JPE 209 does not jump and the program carries on at 206. LDD 83 loads 9. ADD #10 makes 19. JMP 210. STO 81 stores 19 at address 81.

Instruction addressACC80818283
1088081
2008
2019
2029
20310
204
2069
20719
208
21019

Rows 200 and 201 (ACC 8 then 9) [1]

Row 202: address 83 = 9 [1]

Rows 203 to 206: ACC 10, no jump at 204, then ACC 9 [1]

Rows 207 to 210: ACC 19, then address 81 = 19 [1]

(b)(i)

To set a bit to 1 and leave the others unchanged, use OR with a mask that has 1 only in the LSB.

OR B00000001

OR B00000001 (or OR #1 or OR &1) [1]

(b)(ii)

XOR with &FE (11111110) flips the left seven bits and leaves the last bit.

01010101 XOR 11111110 = 10101011 [1]

(b)(iii)

LSR #5 shifts right 5 places: the five right-hand bits fall off and zeros enter on the left.

01101011 → 00000011 [1]

KEY IDEATrace one instruction at a time and only write what changes; use OR to set bits and XOR to flip them.
TOTAL 7 marks

Official mark scheme

Mark scheme for 9618/11/M/J/25 question 8
VIDEO
▶ Starts at Q8 (2:16:19)

Starts at Q8 (2:16:19) · by Pseudocode Pro. 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.