9618/31/M/J/22 question 9: worked solution (May/June 2022, paper 31)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2. Q5 9618/31/M/J/22 original Q9 Structured · 10 marks Worked solution (a) LDM loads the number itself. LDD uses the address as given. LDI uses the address stored at that address. Instruction Addressing mode Contents of ACC LDM #500 Immediate 500 LDD 500 Direct 100 LDI 500 Indirect 20 LDM #500: Immediate and 500 [1] LDD 500: Direct and 100 [1] LDI 500: Indirect and 20 , because address 500 holds 100 and address 100 holds 20 [1] (b) Load 20 and store it in a labelled location. Then use LDI to load the value whose address is held in Y, add 20 and store in Z. Data locations go after the program code. LDM #20 STO Twenty LDI Y ADD Twenty STO Z Twenty: #20 Y: Z: LDM #20 is seen [1] The value 20 is stored at an address ( STO Twenty ) [1] That address is labelled (for example Twenty: ) away from the program code [1] Addresses labelled Y: and Z: away from the program code [1] Correct use of LDI Y [1] Correct use of STO Z [1] Correct use of ADD with the labelled address of 20 [1] Any suitable label name is fine. KEY IDEA Immediate uses the number itself, direct uses the address given, and indirect follows the address stored at that address. TOTAL 10 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.