Past-paper question · 2017 October-November · Paper 43 · Q4(a)

Question 4(a) 2017 · October-November · Paper 43 · 11 marks

Original past-paper question for 4(A)
Original past-paper question for 4(A)
Reveal official mark-scheme answer Official mark-scheme answer for 4(A)

Official answer for Question 4

Part (a)

Question 11

✓
Label
✓
Op code
✓
Operand
✓
Comment
✓
Marks
✓
START:
✓
LDM
✓
#63
✓
// load ASCII value for '?'
✓
OUT
✓
// OUTPUT '?'

Question 1

✓
IN
✓
// input GUESS

Question 1

✓
CMP
✓
LETTERTOGUESS
✓
// compare with stored letter

Question 1

✓
JPE
✓
GUESSED
✓
// if correct guess, go to

Question 1

✓
GUESSED
✓
LDD
✓
ATTEMPTS
✓
// increment ATTEMPTS

Question 1

✓
INC
✓
ACC

Question 1

✓
STO
✓
ATTEMPTS

Question 1

✓
CMP
✓
#9
✓
// is ATTEMPTS = 9 ?

Question 1

✓
JPE
✓
ENDP
✓
// if out of guesses, go to ENDP

Question 1

✓
JMP
✓
START
✓
// go back to beginning of loop

Question 1

✓
GUESSED:
✓
LDM
✓
#42
✓
// load ASCII for '*'
✓
OUT
✓
// OUTPUT '*'

Question 1

✓
ENDP:
✓
END
✓
// end program
✓
ATTEMPTS:
✓
0
✓
LETTERTOGUESS:
✓
'a'
✓
9608/43
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2017
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w17_ms_43.pdf →

Show text version of question

Question 4

Part (a)

Question 4

The following table shows part of the instruction set for a processor. The processor 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. LDD <address> Direct addressing. Load the contents of the location at the given address to ACC. LDI <address> Indirect addressing. The address to be used is at the given address. Load the contents of this second address to ACC. LDX <address> Indexed addressing. Form the address from <address> + the contents of 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. STX <address> Indexed addressing. Form the address from <address> + the contents of 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. JPE <address> Following a compare instruction, jump to <address> if the compare was True. JPN <address> Following a compare instruction, jump to <address> if the compare was False. LSL #n Bits in ACC are shifted n places to the left. Zeros are introduced on the right hand end. LSR #n Bits in ACC are shifted n places to the right. Zeros are introduced on the 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 7

Part (a)

A program stores a letter. The user is allowed nine attempts to guess the stored letter. The

program outputs “?” and the user guesses a letter. If the user guesses the letter, the program outputs “*”.

The following is pseudocode for this program.

REPEAT OUTPUT '?' INPUT GUESS IF GUESS = LETTERTOGUESS THEN OUTPUT '*' BREAK ELSE ATTEMPTS ATTEMPTS + 1 ENDIF UNTIL ATTEMPTS = 9

Write this program. Use the op codes from the instruction set provided.

Label Op code Operand Comment START: LDM #63 // load ASCII value for '?' // OUTPUT '?' // input GUESS // compare with stored letter // if correct guess, go to GUESSED

// increment ATTEMPTS

// is ATTEMPTS = 9 ? // if out of guesses, go to ENDP // go back to beginning of loop GUESSED: LDM #42 // load ASCII for '*' // OUTPUT '*' ENDP: END // end program ATTEMPTS: 0 LETTERTOGUESS: 'a'

[11]

Question 8

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

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

Keep practising this topic