9618/12/O/N/22 question 7: worked solution (October/November 2022, 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. Q22 9618/12/O/N/22 original Q7 Structured · 12 marks Worked solution (a) LDX 110 reads address 110 + IX. CMI 102 compares ACC with the contents of the address held in 102 (that is, address 112, which holds 0). Blank cells mean no change. Instruction address ACC IX 100 101 102 103 110 111 112 0 0 112 4 1 4 0 75 0 76 1 77 78 79 80 84 2 85 2 86 0 87 1 88 1 89 1 90 76 4 77 78 79 80 81 6 82 6 83 86 1 87 2 88 2 89 2 90 Rows 75 to 80 (IX = 0, ACC = 1, both compares False, jump to 84) [1] Rows 84 to 90 (ACC = 2, 101 = 2, ACC = 0, then 1, 100 = 1, IX = 1) [1] Rows 76 to 80 second time (ACC = 4, CMI is False, CMP 103 is True so no jump) [1] Rows 81 to 83 (ACC = 6, 101 = 6, jump to 86) [1] Rows 86 to 90 (ACC = 1, then 2, 100 = 2, IX = 2, stop at 90) [1] (b)(i) XOR flips the bits where the operand has 1: 01010011 XOR 00011111. 01001100 [1] (b)(ii) Address 50 holds 01001101. 01010011 AND 01001101. 01000001 [1] (b)(iii) Shift left 3 places and fill the right with zeros: 01010011 → 10011000. 10011000 [1] (b)(iv) Address 51 holds 10001111. 01010011 OR 10001111. 11011111 [1] (c) Description Register transfer notation Copy the address of the next instruction into the MAR MAR ← [PC] Increment the Program Counter PC ← [PC] + 1 Copy the contents of the MDR into the CIR CIR ← [MDR] MAR ← [PC] [1] PC ← [PC] + 1 [1] CIR ← [MDR] [1] KEY IDEA CMI compares with the contents of the address stored at the given address, and the register transfer notation follows the order MAR, PC, MDR, CIR. TOTAL 12 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Audere Prep. Tap the picture to open it on YouTube.