9618/13/O/N/24 question 7: worked solution (October/November 2024, 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. Q30 9618/13/O/N/24 original Q7 Structured · 6 marks Worked solution (a) Start each program with ACC = 50. Program 1: LDD 50 loads 54. ADD #4 gives 58. ADD 54 adds the contents of address 54 (100): 58 + 100 = 158. Program 2: LDI 53: address 53 holds 52, so load the contents of address 52, which is 50. DEC ACC gives 49. ADD 56 adds 50: 99. Program 3: LDM #55 puts 55 in ACC. SUB #5 gives 50. Instructions ACC content LDD 50, ADD #4, ADD 54 158 LDI 53, DEC ACC, ADD 56 99 LDM #55, SUB #5 50 Program 1 = 158 [1] Program 2 = 99 [1] Program 3 = 50 [1] (b) Clearing means setting every bit to 0 . [1] Use a bitwise AND with a mask of all 0s, so every bit becomes 0 whatever it was before. Then you can compare the result with 0 to check the register is cleared. [1] Instruction: AND B00000000 The instruction AND B00000000 (or AND #0 or AND &00) [1] KEY IDEA ANDing with all zeros clears a register; ORing with a 1 sets a bit. TOTAL 6 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.