Cambridge AS Level Computer Science 9618 · 4.2 Assembly Language

Q33 · 9618/13/M/J/25 Q5

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

Q339618/13/M/J/25original Q5Structured · 9 marks
Question 5 from 9618/13/M/J/25

Worked solution

(a)(i)

Run the program from address 500, writing only what changes.

LDM #50 gives 50. DEC ACC gives 49. CMP 51 compares 49 with 48: false, so the program goes on to 504 (JMP 501). The first pass runs 500, 501, 502 and then 504. Second pass: DEC ACC gives 48. CMP 51 compares 48 with 48: true, so JPE 505 jumps. STO 50 stores 48 at address 50. SUB #10 gives 38. STO 51 stores 38 at address 51.

Instruction addressACC50515253
47484950
50050
50149
502
504
50148
502
503
50548
50638
50738

First four rows: ACC 50, 49, then 502 and 504 [1]

Second pass rows 501 to 505: ACC 48, then address 50 = 48 [1]

Row 506 ACC = 38 and row 507 address 51 = 38 [1]

(a)(ii)

Name two modes of addressing and describe each. Any two of these:

Indirect: the operand points to the memory location that holds the address of the data.

Indexed: the address of the data is the operand plus the contents of the Index Register (IX).

Direct: the operand is the address of the data.

Two modes named correctly [2]

Two matching descriptions correct [2]

(b)

Clear the register first, then set only the top bit.

AND B00000000
OR B10000000

AND with all 0s clears every bit (also accepted: AND #0 or AND &0) [1]

OR with 10000000 sets only the most significant bit (also accepted: OR #128 or OR &80) [1]

KEY IDEAA loop with a compare and a conditional jump may run the same instructions more than once, so list every pass in the trace.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/13/M/J/25 question 5
VIDEO
▶ Whole paper

Video solution of the whole paper · by Ismail Adeleke. 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.