9618/13/O/N/22 question 6: worked solution (October/November 2022, paper 13)

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. Q23 9618/13/O/N/22 original Q6 Structured · 10 marks Worked solution (a)(i) Run the program one line at a time. The first time round, the loop count in address 100 is 1, so the program reads the character 97 (a lower-case letter) and subtracts 32 to get 65. This matches the compare with 65, so it adds 1 to the count in address 101. IX moves on and address 100 becomes 2. On the second pass the count is 2, so the program jumps to address 91 and outputs the count. Instruction address ACC IX 100 101 110 111 112 Output 1 0 97 98 97 75 0 76 1 77 78 79 97 80 65 81 82 83 1 84 85 1 86 87 2 88 2 89 1 90 76 77 78 91 1 92 49 93 1 94 Rows 75 to 78 correct [1] Rows 79 to 82 correct [1] Rows 83 to 90, then 76, 77 and 78 on the second pass, correct [1] Rows 91 to 94 correct, with output 1 [1] (a)(ii) Write the purpose of relative addressing: It allows the code to be re-locatable (loaded anywhere in memory) [1] ... because every target address is given as the base address + an offset [1] (b)(i) AND gives 1 only where both bits are 1. 00110110 AND 01001100 = 00000100 [1] (b)(ii) OR gives 1 where either bit is 1. 10010101 OR 01001111 = 11011111 [1] (b)(iii) Shift every bit 2 places right and put 0s in on the left. 10011101 becomes 00100111 [1] (c) Write one other group, for example input and output of data [1] Other accepted groups: arithmetic operations; unconditional and conditional instructions; compare instructions. KEY IDEA Trace line by line and copy a value into the table only when it changes; relative addressing means base address + offset. TOTAL 10 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.