Past-paper question · 2018 October-November · Paper 33 · Q6(d)(ii)

Question 6(d)(ii) 2018 · October-November · Paper 33 · 5 marks

Original past-paper question for 6(D)(II)
Original past-paper question for 6(D)(II)
Original past-paper question for 6(D)(II)
Original past-paper question for 6(D)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 6(D)(II)

Official answer for Question 6

Part (d)

(ii)

Question 1

mark for each of the following:

Question 5

✓
•
✓
LDD
✓
236
✓
ADD
✓
237
✓
STO
✓
512
✓
ADD
✓
238
✓
STO
✓
513
✓
ADD
✓
239
✓
STO
✓
514
✓
•
✓
Remove line 4 LDD 236 correct lines 3 and 6 in original code
✓
•
✓
Remove line 5 ADD 237 correct lines 3 and 6 in original code
✓
•
✓
Remove line 8 and 9 LDD 236 and ADD 237 correct lines 7 and 11 in
✓
original code
✓
•
✓
Remove line 10 ADD 238 correct lines 7 and 11 in original code

Mark scheme 9608_w18_ms_33.pdf →

Show text version of question

Question 6

Part (d)

(ii)

Question 6

The compilation process has a number of stages. The first stage is lexical analysis.

A
compiler uses a keyword table and a symbol table. Part of the keyword table is shown.
  • Tokens for keywords are shown in hexadecimal.
  • All of the keyword tokens are in the range 00 – 5F.

Keyword Token 01 * 02 = 03

IF 4A THEN 4B ENDIF 4C ELSE 4D FOR 4E STEP 4F TO 50 INPUT 51 OUTPUT 52 ENDFOR 53

Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).

Study the following code.

Start 1 INPUT Number // Output values in a loop FOR Counter Start TO 12 OUTPUT Number * Counter ENDFOR

Question 13

The final stage of compilation is optimisation.

(ii)

A student uses the compiler to compile some different code.

After the syntax analysis stage is complete, the compiler generates object code.

The following lines of code are compiled.

X A + B Y A + B + C Z A + B + C + D

The compilation produces the following assembly language code.

LDD 236 // loads value A to accumulator ADD 237 // adds value B to accumulator STO 512 // stores accumulator in X LDD 236 // loads value A to accumulator ADD 237 // adds value B to accumulator ADD 238 // adds value C to accumulator STO 513 // stores accumulator in Y LDD 236 // loads value A to accumulator ADD 237 // adds value B to accumulator ADD 238 // adds value C to accumulator ADD 239 // adds value D to accumulator STO 514 // stores accumulator in Z

Rewrite the assembly language code after it has been optimised.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

Question 15

Question 16

Permission to reproduce items where third‑party owned material protected by copyright is included has been sought and cleared where possible. Every reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer‑related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

76% assigned-topic match · Processor fundamentals › Assembly language

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_w18_qp_33.pdf

Keep practising this topic