AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Fundamentals of Computer Organisation and Architecture
Machine-Code Operations
- 1 thing to know
- Paper 2
Overview
Recall questions on the instruction set at this level and on the load, store, add and subtract instructions.
What you need to know
Answer each one before you reveal it.
Questions from this subtopic
Each one with the model answer underneath.
- 1
Which basic machine-code operations make up the instruction set used at this level?
Model answer
Load, add, subtract, store, branching both conditional and unconditional, compare, the logical bitwise operators AND, OR, NOT and XOR, logical shift right, logical shift left, and halt.
- 2
What does a load instruction do?
Model answer
It copies a value into a register in the processor. With direct addressing it copies the contents of a given memory location into the register, for example LDR R1, 100 puts the contents of location 100 into register 1. The value in memory is unchanged: load copies, it does not move. An instruction that puts an immediate constant into a register, such as MOV R1, #7, does the same job for a fixed value.
- 3
What does a store instruction do, and how is it the opposite of load?
Model answer
It copies the contents of a register out to a memory location, for example STR R1, 100 writes the contents of register 1 into location 100, overwriting whatever was there. Load brings a value into the processor and store sends it back out. A program typically loads its variables into registers, works on them, and stores the results back before halting.
- 4
Describe the add and subtract instructions.
Model answer
Add takes two operands, adds them in the arithmetic logic unit and places the result in a destination register, for example ADD R0, R1, #5 puts the contents of R1 plus 5 into R0, and ADD R0, R1, R2 puts the sum of the two registers into R0. Subtract works the same way and subtracts the second operand from the first, so SUB R0, R1, #5 puts the contents of R1 minus 5 into R0. Both set the flags in the status register according to the result.
- 5
What does a compare instruction do?
Model answer
It compares two values, typically by subtracting the second from the first inside the arithmetic logic unit, and sets the flags in the status register according to the outcome, for example setting the zero flag if the two were equal and the negative flag if the first was smaller. Crucially it discards the result of the subtraction, so neither operand is changed: its only effect is on the flags. It is therefore always followed by a conditional branch, which reads those flags.
- 6
Explain the difference between an unconditional and a conditional branch.
Model answer
An unconditional branch always transfers control: the branch address is copied into the program counter every time the instruction is executed, so the following instruction is never reached. A conditional branch first tests a flag in the status register, set by the preceding compare or arithmetic instruction, and copies the address into the program counter only if the condition is satisfied; otherwise the program counter keeps its incremented value and execution continues in sequence. Conditional branches are how selection and iteration are built in machine code, since the high-level IF and WHILE constructs have no direct equivalent.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Fundamentals of Computer Organisation and Architecture, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.