9618/11/M/J/25 question 8: worked solution (May/June 2025, paper 11)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language Worked solution from the Processor Fundamentals Paper 1 Theory Fundamentals booklet, Part 2 of 3. Q31 9618/11/M/J/25 original Q8 Structured · 7 marks 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 address ACC 80 81 82 83 10 8 80 81 200 8 201 9 202 9 203 10 204 206 9 207 19 208 210 19 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 IDEA Trace 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 VIDEO ▶ Starts at Q8 (2:16:19) Starts at Q8 (2:16:19) · by Pseudocode Pro. Tap the picture to open it on YouTube.