9618/12/M/J/21 question 4: worked solution (May/June 2021, paper 12)

Show as 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. Q18 9618/12/M/J/21 original Q4 Structured · 8 marks Worked solution (a) First input is A (65). It is not equal to the value at 100 (68) but equals the value at 101 (65), so the program jumps to 76 and adds 1 to the value in 102. Second input is D (68). It equals the value at 100, so the program jumps to 80 and subtracts 1 from 102. Blank cells mean no change. Instruction address ACC 100 101 102 68 65 100 70 65 71 72 73 74 76 100 77 101 78 101 79 70 68 71 72 80 101 81 100 82 100 83 (70) Input 65 into ACC (rows 70 to 74) [1] Load 100, increment to 101 and store in 102 (rows 76 to 79) [1] Input 68 into ACC (rows 70 to 72) [1] Load 101 into ACC, decrement to 100 and store in 102 (rows 80 to 83) [1] (b)(i) Bit values: 64 + 32 + 4 + 2 = 102. 102 [1] (b)(ii) AND with a mask that has only bit 2 set (#4 = 00000100). The result is non-zero only if bit 2 is 1. AND [1] (b)(iii) AND with 00001111, which is 15. Bits 4 to 7 become 0 and bits 0 to 3 stay the same. Opcode AND [1] Operand #15 [1] KEY IDEA To clear chosen bits use AND with a mask that has 0 in those bits and 1 in the bits to keep. TOTAL 8 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by O/Alevel CS by Wasiq. Tap the picture to open it on YouTube.