Past-paper question · 2017 May-June · Paper 41 · Q1(b)

Question 1(b) 2017 · May-June · Paper 41 · 7 marks

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

Official answer for Question 1

Part (b)

Question 7

✓
START:
✓
LDD
✓
NUMBER

Question 1

✓
// set to zero all
✓
AND
✓
MASK
✓
bits except sign

Question 1

✓
bit
✓
CMP
✓
#0
✓
// compare with 0

Question 1

✓
// if not equal jump
✓
JPN
✓
ELSE

Question 1

✓
to ELSE
✓
// load ACC with 'P'
✓
THEN:
✓
LDM
✓
#80

Question 1

✓
(ASCII value 80)
✓
JMP
✓
ENDIF
✓
// load ACC with 'N'
✓
ELSE:
✓
LDM
✓
#78
✓
(ASCII value 78)
✓
ENDIF:
✓
OUT
✓
//output character

Question 1

✓
END
✓
// integer to be
✓
NUMBER:
✓
B00000101
✓
tested
✓
// show value of
✓
MASK:
✓
B10000000
✓
mask in binary

Question 1

✓
here
✓
9608/41
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s17_ms_41.pdf →

Show text version of question

Question 1

Part (b)

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 Op Explanation Operand code LDM #n Immediate addressing. Load the number n to ACC. Direct addressing. Load the contents of the location at the given address LDD <address> to ACC. Indirect addressing. The address to be used is at the given address. LDI <address> Load the contents of this second address to ACC. Indexed addressing. Form the address from <address> + the contents of LDX <address> 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). 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>. JMP <address> Jump to given address. Following a compare instruction, jump to <address> if the compare was JPE <address> True. Following a compare instruction, jump to <address> if the compare was JPN <address> False. Bitwise AND operation of the contents of ACC with the contents of AND <address> <address>. Bitwise XOR operation of the contents of ACC with the contents of XOR <address> <address>. Bitwise OR operation of the contents of ACC with the contents of OR <address> <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 (b)

The programmer now starts to write a program that:

  • tests whether an 8-bit two’s complement integer stored at address NUMBER is positive or
  • negative

  • outputs 'P' for a positive integer and 'N' for a negative integer.

Complete the following program. Use op codes from the given instruction set. Show the required value of MASK in binary.

Label Op code Operand Comment START:

MASK // set to zero all bits except sign bit

// compare with 0

// if not equal jump to ELSE

THEN: // load ACC with 'P' (ASCII value 80)

JMP ENDIF

ELSE: // load ACC with 'N' (ASCII value 78)

ENDIF:

END

NUMBER: B00000101 // integer to be tested

MASK: // value of mask in binary

[7]

Question 4

Topic relevance

Why this question appears here

72% assigned-topic match · Information representation › Data representation

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

Keep practising this topic