9618/11/O/N/22 question 6: worked solution (October/November 2022, 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. Q21 9618/11/O/N/22 original Q6 Structured · 11 marks 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 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] (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) 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] KEY IDEA Indexed addressing reads address + IX, and a trace table only changes the cell that each instruction changes. TOTAL 11 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.