The table shows the contents of memory locations before a program runs. A program is run using the AQA assembly language instruction set.
| Address | 100 | 101 | 102 |
|---|---|---|---|
| Contents | 14 | 9 | 0 |
LDR R0, 100
LDR R1, 101
ADD R2, R0, R1
SUB R2, R2, #5
STR R2, 102
HALT(a) State the value in R2 after the ADD instruction executes. [1]
(b) State the value in R2 after the SUB instruction and the value stored in location 102 when the program ends. [2]
(c) State the purpose of the HALT instruction. [1]
- 23(1)
- 18 in R2 after SUB(1)
- 18 in location 102 (after STR)(1)
- Stops the program / processor execution(1)
- Answer: (a) 23 (b) R2 = 18, location 102 = 18 (c) stops execution
- Examiner tip: Remember that SUB R2, R2, #5 overwrites R2; students often keep 23 for the store.