Past-paper question · 2016 October-November · Paper 41 · Q3

Question 3 2016 · October-November · Paper 41 · 15 marks

Original past-paper question for 3
Original past-paper question for 3
Reveal official mark-scheme answer Official mark-scheme answer for 3Official mark-scheme answer for 3

Official answer for Question 3

✓
START:
✓
LDR
✓
#0
✓
// initialise index register to zero
[1]
✓
LDM
✓
#0
✓
// initialise COUNT to zero
[1]
✓
STO
✓
COUNT
✓
// load character from indexed address
✓
LOOP1:
✓
LDX
✓
NAME
[1]
✓
NAME
✓
OUT
✓
// output character to screen
[1]
✓
INC
✓
IX
✓
// increment index register
[1]
✓
LDD
✓
COUNT
✓
// increment COUNT starts here
✓
INC
✓
ACC
[1]
✓
STO
✓
COUNT
✓
CMP
✓
// is COUNT = MAX?
[1]
✓
JPN
✓
LOOP1
✓
// if FALSE, jump to LOOP1
[1]
✓
REVERSE: DEC
✓
IX
✓
// decrement index register
[1]
✓
LDM
✓
#0
✓
// set ACC to zero
[1]
✓
STO
✓
COUNT
✓
// store in COUNT
✓
// load character from indexed address
✓
LOOP2:
✓
LDX
✓
NAME
✓
NAME
[1]
✓
OUT
✓
// output character to screen
✓
DEC
✓
IX
✓
// decrement index register
[1]
✓
LDD
✓
COUNT
✓
// increment COUNT starts here
✓
INC
✓
ACC
✓
//
[1]
✓
STO
✓
COUNT
✓
//
✓
CMP
✓
// is COUNT = MAX?
[1]
✓
JPN
✓
LOOP2
✓
// if FALSE, jump to LOOP2
✓
END
✓
// end of program
[1]
✓
COUNT:

Question 4

✓
NAME:
✓
B01000110
✓
// ASCII code in binary for 'F'
✓
B01010010
✓
// ASCII code in binary for 'R'
✓
B01000101
✓
// ASCII code in binary for 'E'
✓
B01000100
✓
// ASCII code in binary for 'D'
✓
[Max 15]
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International A Level – October/November 2016
✓
9608

Question 41

Mark scheme 9608_w16_ms_41.pdf →

Show text version of question

Question 3

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 Op Explanation Operand code LDM #n Immediate addressing. Load the number n to ACC. LDD <address> Direct addressing. Load the contents of the given address to ACC. Indexed addressing. Form the address from <address> + the contents LDX <address> of the index register. Copy the contents of this calculated address to ACC. LDR #n Immediate addressing. Load the number n into IX. STO <address> Store the contents of ACC at the given address. 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). 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 JPE <address> was True. Following a compare instruction, jump to <address> if the compare JPN <address> was False. Output to the screen the character whose ASCII value is stored in OUT ACC. END Return control to the operating system.

A
programmer is writing a program that outputs a string, first in its original order and then in

reverse order.

The program will use locations starting at address NAME to store the characters in the string. The location with address MAX stores the number of characters that make up the string.

The programmer has started to write the program in the table opposite. The Comment column contains descriptions for the missing program instructions.

Complete the program using op codes from the given instruction set.

Question 15

Op Label Operand Comment code START: // initialise index register to zero

// initialise COUNT to zero

LOOP1: // load character from indexed address NAME

// output character to screen

// increment index register

// increment COUNT starts here

// is COUNT = MAX ?

// if FALSE, jump to LOOP1

REVERSE: // decrement index register

// set ACC to zero

// store in COUNT

LOOP2: // load character from indexed address NAME

// output character to screen

// decrement index register

// increment COUNT starts here

// is COUNT = MAX ?

// if FALSE, jump to LOOP2

// end of program

COUNT:

MAX: 4

NAME: B01000110 // ASCII code in binary for 'F'

B01010010 // ASCII code in binary for 'R'

B01000101 // ASCII code in binary for 'E'

B01000100 // ASCII code in binary for 'D'

[15]

Question 16

Topic relevance

Why this question appears here

82% assigned-topic match · Processor fundamentals › Assembly language

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

Keep practising this topic