Question 5(a) 2017 · October-November · Paper 42 · 10 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (a)
Question 10
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 5
Part (a)
Question 5
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 9
Part (a)
Six letters are stored, starting at the location labelled LETTERS. A program is needed to
perform a linear search on LETTERS to find the letter 'x'. The program counts the number of times 'x' appears in LETTERS.
The following is the pseudocode for the program.
FOR COUNT 0 TO 5 IF LETTERS[COUNT] = LETTERTOFIND THEN FOUND FOUND + 1 ENDIF ENDFOR
Write this program. Use the op codes from the given instruction set.
Label Op code Operand Comment START: LDR #0 // initialise Index Register LOOP: // load LETTERS // is LETTERS = LETTERTOFIND ? // if not, go to NOTFOUND
// increment FOUND
NOTFOUND: // increment COUNT
// is COUNT = 6 ? // if yes, end // increment Index Register // go back to beginning of loop ENDP: END // end program LETTERTOFIND: 'x' LETTERS: 'd' 'u' 'p' 'l' 'e' 'x' COUNT: 0 FOUND: 0
Question 10
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_w17_qp_42.pdf
