levo

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.

Your recallNot started
Evaluation

Explain the difference between an unconditional and a conditional branch.

Questions from this subtopic

Each one with the model answer underneath.

  1. 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. 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. 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. 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. 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. 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.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A driver is .
softwarehardwarestorage

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AThe integer 5 is 0101.
B0.75 is 1/2 + 1/4.
CThe fraction bits are 1100.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

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.