Past-paper question · 2017 May-June · Paper 42 · Q1(a)

Question 1(a) 2017 · May-June · Paper 42 · 9 marks

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

Official answer for Question 1

Part (a)

Question 9

✓
Op
✓
Label
✓
Operand
✓
Comment
✓
code
✓
START:
✓
IN
✓
// INPUT character

Question 1

✓
STO
✓
CHAR1
✓
// store in CHAR1
✓
IN
✓
// INPUT character

Question 1

✓
STO
✓
CHAR2
✓
// store in CHAR2
✓
LDD
✓
CHAR1
✓
// initialise ACC to ASCII value of CHAR1

Question 1

✓
LOOP:
✓
OUT
✓
//output contents of ACC
✓
1+1
✓
CMP
✓
CHAR2
✓
// compare ACC with CHAR2

Question 1

✓
JPE
✓
ENDFOR
✓
// if equal jump to end of FOR loop

Question 1

✓
INC
✓
ACC
✓
// increment ACC

Question 1

✓
JMP
✓
LOOP
✓
// jump to LOOP

Question 1

✓
ENDFOR:
✓
END
✓
CHAR1:
✓
CHAR2:

Mark scheme 9608_s17_ms_42.pdf →

Show text version of question

Question 1

Part (a)

Question 1

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. 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. STO <address> Store the contents of ACC at the given address. INC <register> Add 1 to the contents of the register (ACC or IX). CMP <address> Compare the contents of ACC with the contents of <address>. JMP <address> Jump to the given address. 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. AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>. XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>. OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>. 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.

Part (a)

A programmer writes a program that:

  • reads two characters input from the keyboard (you may assume they will be capital
  • letters in ascending alphabetical sequence)

  • outputs the alphabetical sequence of characters from the first to the second character.

For example, if the characters ‘B’ and ‘F’ are input, the output is:

BCDEF

Question 3

The programmer has started to write the program in the following table. The Comment column contains descriptions for the missing program instructions, labels and data.

Complete the following program. Use op codes from the given instruction set.

Op Label Operand Comment code START: // INPUT character // store in CHAR1 // INPUT character // store in CHAR2 // initialise ACC to ASCII value of CHAR1 // output contents of ACC // compare ACC with CHAR2 // if equal jump to end of FOR loop // increment ACC // jump to LOOP ENDFOR: END CHAR1: CHAR2:

[9]
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_s17_qp_42.pdf

Keep practising this topic