Question 4(a) 2017 · October-November · Paper 41 · 11 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (a)
Question 11
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
Question 1
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'
Question 8
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_41.pdf
