Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q30 · 9618/13/O/N/24 Q7

Worked solution from the Processor Fundamentals Paper 1 Theory Fundamentals booklet, Part 2 of 3.

Q309618/13/O/N/24original Q7Structured · 6 marks
Question 7 from 9618/13/O/N/24

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.

InstructionsACC content
LDD 50, ADD #4, ADD 54158
LDI 53, DEC ACC, ADD 5699
LDM #55, SUB #550

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 IDEAANDing with all zeros clears a register; ORing with a 1 sets a bit.
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/13/O/N/24 question 7
VIDEO
▶ Whole paper

Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.