Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q23 · 9618/13/O/N/22 Q6

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

Q239618/13/O/N/22original Q6Structured · 10 marks
Question 6 from 9618/13/O/N/22

Worked solution

(a)(i)

Run the program one line at a time. The first time round, the loop count in address 100 is 1, so the program reads the character 97 (a lower-case letter) and subtracts 32 to get 65. This matches the compare with 65, so it adds 1 to the count in address 101. IX moves on and address 100 becomes 2. On the second pass the count is 2, so the program jumps to address 91 and outputs the count.

Instruction addressACCIX100101110111112Output
10979897
750
761
77
78
7997
8065
81
82
831
84
851
86
872
882
891
90
76
77
78
911
9249
931
94

Rows 75 to 78 correct [1]

Rows 79 to 82 correct [1]

Rows 83 to 90, then 76, 77 and 78 on the second pass, correct [1]

Rows 91 to 94 correct, with output 1 [1]

(a)(ii)

Write the purpose of relative addressing:

It allows the code to be re-locatable (loaded anywhere in memory) [1]

... because every target address is given as the base address + an offset [1]

(b)(i)

AND gives 1 only where both bits are 1.

00110110 AND 01001100 = 00000100 [1]

(b)(ii)

OR gives 1 where either bit is 1.

10010101 OR 01001111 = 11011111 [1]

(b)(iii)

Shift every bit 2 places right and put 0s in on the left.

10011101 becomes 00100111 [1]

(c)

Write one other group, for example input and output of data [1]

Other accepted groups: arithmetic operations; unconditional and conditional instructions; compare instructions.

KEY IDEATrace line by line and copy a value into the table only when it changes; relative addressing means base address + offset.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/13/O/N/22 question 6
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. 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.