📄 Paper 1 · 4.7 Computer Org & Architecture
4.7.5 Machine Code, Assembly Language & Addressing
AQA 7517 · A-Level Computer Science · ~14 min read

Machine Code

Machine code is the only language the CPU can execute directly — binary instructions that control the processor. Each instruction consists of:

  • Opcode: specifies the operation (e.g. ADD, LOAD, JUMP) — binary pattern recognised by the CU
  • Operand: the data or memory address the operation acts on

Example: 00100011 00001010 — opcode (LOAD) followed by operand (address 10 in binary)

Instruction Set Architecture (ISA)

The instruction set is the complete set of machine code operations a CPU can perform. Different CPU architectures (x86, ARM) have different instruction sets — meaning code compiled for one architecture does not run on another (portability problem).

Assembly Language

Assembly language is a low-level language that uses human-readable mnemonics instead of binary. Each assembly instruction maps directly to one machine code instruction.

LDR R0, 100    ; Load value from memory address 100 into register R0
ADD R1, R0, #5 ; Add 5 to R0, store result in R1
STR R1, 200    ; Store R1 into memory address 200
CMP R1, #20    ; Compare R1 with 20
BEQ END        ; Branch to END if equal

Assembly is converted to machine code by an assembler.

Addressing Modes

ModeDescriptionExample
ImmediateOperand IS the value to useADD R0, #5 → add 5 directly
DirectOperand is a memory address containing the valueLDR R0, 200 → load value at address 200
IndirectOperand is address of address — follow the pointerOperand 200 holds another address 500; load value at 500
RegisterOperand is a registerADD R0, R1 → add contents of R1 to R0

Status Registers and Flags

After ALU operations, flag bits in the status register are updated:

  • Zero flag (Z): set if result = 0
  • Carry flag (C): set if arithmetic overflows beyond word size
  • Negative flag (N): set if result is negative
  • Overflow flag (V): set if signed overflow occurs

Conditional branch instructions (BEQ, BNE, BGT) check these flags to decide whether to branch.

Instruction Formats

A typical 16-bit instruction word:

  • Bits 15–12: Opcode (4 bits → 16 possible operations)
  • Bits 11–8: Destination register
  • Bits 7–0: Operand (address or immediate value)
Exam tip: Know opcode and operand definitions. Be able to trace through a short assembly program. Know all four addressing modes and when each is used. Know the four main flags. AQA often sets questions where you trace or extend an assembly sequence — practice step by step. Assembler vs compiler: assembler converts assembly 1:1 to machine code; compiler does many-to-one (high level → machine code).
Click through the slides at your own pace. Use arrow keys or click to advance.
Click slide or press arrow keys to navigate

Worksheet — 4.7.5 Machine Code & Assembly

8 questions · instantly marked · AQA 7517 standard

Q1Explain the difference between the opcode and the operand in a machine code instruction.[2]
✅ Mark scheme
Mark scheme
The opcode specifies the operation to perform (e.g. LOAD, ADD, JUMP) [1]; the operand specifies the data or memory address the operation acts on [1].
Q2What is the role of an assembler?[2]
✅ Mark scheme
Mark scheme
An assembler translates assembly language into machine code [1]; each assembly mnemonic maps directly to one machine code instruction (one-to-one translation) [1].
Q3Explain the difference between immediate and direct addressing modes.[4]
✅ Mark scheme
Mark scheme
Immediate addressing: the operand IS the actual value to be used (no memory access needed) [1]; e.g. ADD R0, #5 adds the literal value 5 to R0 [1]. Direct addressing: the operand is a memory address — the CPU accesses that address to get the value [1]; e.g. LDR R0, 200 loads the value stored at memory address 200 [1].
Q4Trace through the following assembly program. State the value in R1 after execution:
LDR R0, #8    ; Load 8 into R0
ADD R1, R0, #3 ; Add 3 to R0 and store in R1
SUB R1, R1, #2 ; Subtract 2 from R1
[3]
✅ Mark scheme
Mark scheme
R0 = 8 [1]; R1 = 8 + 3 = 11 [1]; R1 = 11 − 2 = 9 [1].
Q5What does the Zero flag (Z) indicate in the status register?[2]
✅ Mark scheme
Mark scheme
The Zero flag is set (= 1) when the result of an ALU operation is zero [1]; it is used by conditional branch instructions (e.g. BEQ — Branch if Equal) to decide whether to jump [1].
Q6Why might machine code written for an Intel x86 CPU not run on an ARM processor?[2]
✅ Mark scheme
Mark scheme
Different CPU architectures have different instruction sets [1]; the binary opcodes and instruction formats used by x86 are not recognised by the ARM processor's Control Unit [1].
Q7Explain what is meant by indirect addressing mode.[2]
✅ Mark scheme
Mark scheme
In indirect addressing, the operand is a memory address that contains another address (a pointer) [1]; the CPU first fetches the address from the operand location, then accesses that second address to get the actual data [1].
Q8If a 4-bit opcode is used, how many different operations can the CPU perform? Explain your answer.[2]
✅ Mark scheme
Mark scheme
A 4-bit opcode allows 2⁴ = 16 different operations [1]; each unique bit pattern represents a different instruction in the CPU's instruction set [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 8
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — Machine Code & Assembly

10 questions · 10 minutes

← 4.7.4 Von Neumann Architecture
53 of 70 · AQA 7517
4.8.1 Ethics & Law →