Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q18 · 9618/12/M/J/21 Q4

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

Q189618/12/M/J/21original Q4Structured · 8 marks
Question 4 from 9618/12/M/J/21

Worked solution

(a)

First input is A (65). It is not equal to the value at 100 (68) but equals the value at 101 (65), so the program jumps to 76 and adds 1 to the value in 102. Second input is D (68). It equals the value at 100, so the program jumps to 80 and subtracts 1 from 102. Blank cells mean no change.

Instruction addressACC100101102
6865100
7065
71
72
73
74
76100
77101
78101
79
7068
71
72
80101
81100
82100
83
(70)

Input 65 into ACC (rows 70 to 74) [1]

Load 100, increment to 101 and store in 102 (rows 76 to 79) [1]

Input 68 into ACC (rows 70 to 72) [1]

Load 101 into ACC, decrement to 100 and store in 102 (rows 80 to 83) [1]

(b)(i)

Bit values: 64 + 32 + 4 + 2 = 102.

102 [1]

(b)(ii)

AND with a mask that has only bit 2 set (#4 = 00000100). The result is non-zero only if bit 2 is 1.

AND [1]

(b)(iii)

AND with 00001111, which is 15. Bits 4 to 7 become 0 and bits 0 to 3 stay the same.

Opcode AND [1]

Operand #15 [1]

KEY IDEATo clear chosen bits use AND with a mask that has 0 in those bits and 1 in the bits to keep.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/12/M/J/21 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by O/Alevel CS by Wasiq. 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.