Question bank › A-level › A-level Computer Science › Fundamentals of computer organisation and architecture

Instruction sets, addressing modes and assembly language

10 questions49 marksabout 60 min

Answer on paper first, then reveal the mark scheme one mark at a time.

1Standard4 marks

The table shows the contents of memory locations before a program runs. A program is run using the AQA assembly language instruction set.

Address100101102
Contents1490
LDR R0, 100
LDR R1, 101
ADD R2, R0, R1
SUB R2, R2, #5
STR R2, 102
HALT

(a) State the value in R2 after the ADD instruction executes. [1]

(b) State the value in R2 after the SUB instruction and the value stored in location 102 when the program ends. [2]

(c) State the purpose of the HALT instruction. [1]

2Standard5 marks
      MOV R0, #1
      MOV R1, #0
loop: ADD R1, R1, R0
      ADD R0, R0, #1
      CMP R0, #5
      BLT loop
      HALT

(a) State the final values in R0 and R1 when the program halts. [2]

(b) State how many times the instruction ADD R1, R1, R0 is executed. [1]

(c) Describe what the program calculates. [1]

(d) State the change needed so that the program calculates the sum of the integers from 1 to 10. [1]

3Hard5 marks

Memory location 200 contains the binary value 10110111.

LDR R0, 200
AND R1, R0, #15
LSL R2, R1, #2
EOR R3, R2, #255
HALT

(a) Give the denary values in R1, R2 and R3 after the program halts. [3]

(b) State the effect of the instruction LSL R2, R1, #2 in terms of multiplication. [1]

(c) State the effect of EOR R3, R2, #255 on an 8-bit value. [1]

Stuck on Instruction sets, addressing modes and assembly language?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4Stretch6 marks

Write an assembly language program, using the AQA instruction set, that:

  • reads a number from memory location 300;
  • stores 1 in memory location 301 if the number is greater than 50;
  • otherwise stores 0 in memory location 301;
  • then stops.

[6]

5Core4 marks

The AQA assembly language instruction set is used. #n denotes an immediate value and a number on its own denotes a memory address.

Memory location 40 contains the value 25 and memory location 41 contains the value 60.

MOV R1, #40
LDR R2, 40
HALT

(a) State the value in register R1 after the program halts. [1]

(b) State the value in register R2 after the program halts. [1]

(c) Explain the difference between immediate addressing and direct addressing. Refer to the two instructions in the program in your answer. [2]

6Standard5 marks

A simple processor uses 12-bit machine code instructions in the format shown in the diagram. The 5-bit opcode is made up of a 4-bit operation code followed by a 1-bit addressing mode. A mode bit of 0 means immediate addressing and a mode bit of 1 means direct addressing. The processor has a single accumulator, and all operands are unsigned binary integers.

Some of the operation codes are:

Operation codeMeaning
0011Load into accumulator
0101Add to accumulator
1000Store accumulator

(a) State the maximum number of different operations this instruction format can support. [1]

(b) State the range of values that can be used as an operand with immediate addressing. [1]

(c) Describe what the processor does when it executes the instruction 010110101100. [2]

(d) Explain one limitation that this instruction format places on direct addressing. [1]

Operation (4 bits) Mode (1 bit) Operand (7 bits) Opcode (5 bits) 12-bit instruction bit 11 bit 0
7Standard4 marks

The AQA assembly language instruction set is used. #n denotes an immediate value and a number on its own denotes a memory address.

Registers hold 8-bit values. Memory location 90 contains the binary value 10010110.

LDR R0, 90
ORR R1, R0, #7
LSR R2, R0, #3
MVN R3, R0
HALT

(a) Give the 8-bit binary values in R1, R2 and R3 after the program halts. [3]

(b) Describe the effect that the instruction ORR R1, R0, #7 has on the bits of the value in R0. [1]

8Hard5 marks

The AQA assembly language instruction set is used. #n denotes an immediate value and a number on its own denotes a memory address.

      LDR R0, 250
      LDR R1, 251
      CMP R0, R1
      BGT first
      SUB R2, R1, R0
      B done
first: SUB R2, R0, R1
done:  STR R2, 252
      HALT

(a) Memory location 250 contains 17 and memory location 251 contains 30. State the value stored in location 252 when the program halts. [1]

(b) Memory location 250 contains 42 and memory location 251 contains 25. State the value stored in location 252 when the program halts. [1]

(c) Describe what the program calculates. [1]

(d) Explain why the instruction B done is needed. Use the values from part (a) in your answer. [2]

9Hard5 marks

The AQA assembly language instruction set is used. #n denotes an immediate value and a number on its own denotes a memory address.

Memory location 120 contains the value 44.

      LDR R0, 120
      MOV R1, #0
loop: AND R2, R0, #1
      ADD R1, R1, R2
      LSR R0, R0, #1
      CMP R0, #0
      BNE loop
      STR R1, 121
      HALT

(a) Give, in order, each value that R0 takes after each execution of LSR R0, R0, #1. [2]

(b) State the value stored in location 121 when the program halts. [1]

(c) State how many times the branch to loop is taken. [1]

(d) Describe the purpose of the program. [1]

10Stretch6 marks

The AQA assembly language instruction set does not include a division instruction.

Write a program in AQA assembly language that:

  • divides the positive integer in memory location 500 by the positive integer in memory location 501 using repeated subtraction;
  • stores the quotient (whole-number result) in memory location 502;
  • stores the remainder in memory location 503;
  • then stops.

You may assume that the value in location 501 is greater than 0. [6]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session