Past-paper question · 2019 October-November · Paper 42 · Q5(b)

Question 5(b) 2019 · October-November · Paper 42 · 8 marks

Original past-paper question for 5(B)
Original past-paper question for 5(B)
Original past-paper question for 5(B)
Original past-paper question for 5(B)
Original past-paper question for 5(B)
Reveal official mark-scheme answer Official mark-scheme answer for 5(B)

Official answer for Question 5

Part (b)

Question 8

✓
Label
✓
Op code
✓
Operand
✓
Comment
✓
LDR
✓
#0
✓
// initialise index register to 0
✓
START:
✓
LDX
✓
STRING
✓
// load the next value from STRING

Question 1

✓
AND
✓
MASK
✓
// bitwise AND operation with MASK

Question 1

✓
CMP
✓
MASK
✓
// check if result equals MASK

Question 1

✓
JPN
✓
UPPER
✓
// if FALSE jump to UPPER

Question 1

✓
LDD
✓
COUNT

Question 1

✓
INC
✓
ACC
✓
// increment COUNT
✓
STO
✓
COUNT
✓
UPPER:
✓
INC
✓
IX
✓
// increment Index Register

Question 1

✓
LDD
✓
LENGTH

Question 1

✓
DEC
✓
ACC
✓
// decrement LENGTH
✓
STO
✓
LENGTH
✓
CMP
✓
#0
✓
// is LENGTH = 0 ?

Question 1

✓
JPN
✓
START
✓
// if FALSE, jump to START

Question 1

✓
END
✓
// end program
✓
9608/42
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November 2019
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_42.pdf →

Show text version of question

Question 5

Part (b)

Question 5

The following table shows part of the instruction set for a processor which has one general purpose

register, the Accumulator (ACC) and an Index Register (IX).

Instruction Explanation Op code Operand LDM #n Immediate addressing. Load the number n to ACC. Direct addressing. Load the contents of the location at the given address to LDD <address> ACC. Indirect addressing. The address to be used is at the given address. Load LDI <address> the contents of this second address to ACC. Indexed addressing. Form the address from <address> + the contents of LDX <address> the Index Register. Copy the contents of this calculated address to ACC. LDR #n Immediate addressing. Load the number n to IX. STO <address> Store the contents of ACC at the given address. Indexed addressing. Form the address from <address> + the contents of STX <address> the Index Register. Copy the contents from ACC to this calculated address. ADD <address> Add the contents of the given address to the ACC. INC <register> Add 1 to the contents of the register (ACC or IX). DEC <register> Subtract 1 from the contents of the register (ACC or IX). JMP <address> Jump to the given address. CMP <address> Compare the contents of ACC with the contents of <address>. CMP #n Compare the contents of ACC with number n. Following a compare instruction, jump to <address> if the compare was JPE <address> True. Following a compare instruction, jump to <address> if the compare was JPN <address> False. AND #n Bitwise AND operation of the contents of ACC with the operand. Bitwise AND operation of the contents of ACC with the contents of AND <address> <address>. XOR #n Bitwise XOR operation of the contents of ACC with the operand. Bitwise XOR operation of the contents of ACC with the contents of XOR <address> <address>. OR #n Bitwise OR operation of the contents of ACC with the operand. Bitwise OR operation of the contents of ACC with the contents of OR <address> <address>. <address> can be an absolute address or a symbolic address. Bits in ACC are shifted n places to the left. Zeros are introduced on the LSL #n right hand end. Bits in ACC are shifted n places to the right. Zeros are introduced on the LSR #n left hand end. IN Key in a character and store its ASCII value in ACC. OUT Output to the screen the character whose ASCII value is stored in ACC. END Return control to the operating system.

Question 15

Part (b)

A programmer needs a program that counts the number of lower case letters in a string.

The programmer has started to write the program in the following table. The comment column contains explanations for the missing program instructions.

Complete the program using the given instruction set. A copy of the instruction set is provided on the opposite page.

Instruction Label Comment Op code Operand LDR #0 // initialise Index Register to 0

START: // load the next value from the STRING

// perform bitwise AND operation with MASK

// check if result is equal to MASK

// if FALSE, jump to UPPER

// increment COUNT

UPPER: INC IX // increment the Index Register

// decrement LENGTH

// is LENGTH = 0 ?

// if FALSE, jump to START

END // end program

MASK: B00100000 // if bit 5 is 1, letter is lower case

COUNT: 0

LENGTH: 5

STRING: B01001000 // ASCII code for 'H'

B01100001 // ASCII code for 'a'

B01110000 // ASCII code for 'p'

B01110000 // ASCII code for 'p'

B01011001 // ASCII code for 'Y'

[8]

Question 17

Instruction Explanation Op code Operand LDM #n Immediate addressing. Load the number n to ACC. Direct addressing. Load the contents of the location at the given address to LDD <address> ACC. Indirect addressing. The address to be used is at the given address. Load LDI <address> the contents of this second address to ACC. Indexed addressing. Form the address from <address> + the contents of LDX <address> the Index Register. Copy the contents of this calculated address to ACC. LDR #n Immediate addressing. Load the number n to IX. STO <address> Store the contents of ACC at the given address. Indexed addressing. Form the address from <address> + the contents of STX <address> the Index Register. Copy the contents from ACC to this calculated address. ADD <address> Add the contents of the given address to the ACC. INC <register> Add 1 to the contents of the register (ACC or IX). DEC <register> Subtract 1 from the contents of the register (ACC or IX). JMP <address> Jump to the given address. CMP <address> Compare the contents of ACC with the contents of <address>. CMP #n Compare the contents of ACC with number n. Following a compare instruction, jump to <address> if the compare was JPE <address> True. Following a compare instruction, jump to <address> if the compare was JPN <address> False. AND #n Bitwise AND operation of the contents of ACC with the operand. Bitwise AND operation of the contents of ACC with the contents of AND <address> <address>. XOR #n Bitwise XOR operation of the contents of ACC with the operand. Bitwise XOR operation of the contents of ACC with the contents of XOR <address> <address>. OR #n Bitwise OR operation of the contents of ACC with the operand. Bitwise OR operation of the contents of ACC with the contents of OR <address> <address>. <address> can be an absolute address or a symbolic address. Bits in ACC are shifted n places to the left. Zeros are introduced on the LSL #n right hand end. Bits in ACC are shifted n places to the right. Zeros are introduced on the LSR #n left hand end. IN Key in a character and store its ASCII value in ACC. OUT Output to the screen the character whose ASCII value is stored in ACC. END Return control to the operating system.

Question 18

Question 19

Question 20

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 Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series.

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

Topic relevance

Why this question appears here

72% assigned-topic match · Hardware › Logic gates and logic circuits

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_w19_qp_42.pdf

Keep practising this topic