GCSE · Computer Science · AQA · Spec 8525

Machine code

Type SUB where you meant ADD and the computer won't blink. It does exactly what you told it, perfectly, and hands you the wrong answer.

Computer Science · Machine code

Four lines of assembly. Four lines of binary. One wrong answer.

This CPU and its codes are invented for illustration, because real CPUs differ. In each instruction the left four bits are the operation code (the action) and the right four bits are a number when the action needs one. ADD = 0001. The programmer's plan: start at 4, add 3 twice, store 10.

Step through it. Before the third line runs, predict: the programmer wanted 10 stored. What will the CPU actually store?

1 LOAD 4
2 ADD 3
3 SUB 3
4 STORE
machine coderunning totalstored
0011 01004-

Output

 

Step 1: LOAD 4 becomes one machine code instruction. 0011 is this CPU's code for load, and 0100 is the number 4. Running total: 4.

1 / 4

Press Next to run one instruction at a time. Watch the machine code column fill in beside each readable line.

Step 1 of 4: LOAD 4 becomes one machine code instruction. 0011 is this CPU's code for load, and 0100 is the number 4. Running total: 4..

Exam line: One assembly instruction becomes one machine code instruction, and the CPU runs it exactly as written. It cannot guess what the programmer meant.
Watch out: Don't read 0001 0011 as one big number. It's an instruction: 0001 is the code for ADD and 0011 is the 3 it adds.

Computer Science · Language levels

Which level has which feature?

Put each feature in every set it belongs to. Some belong to two.

  • A Machine code
  • B Assembly language
  • C High-level language
  1. Written using only 1s and 0s
  2. Executed directly by the CPU
  3. A low-level language
  4. Gives direct control over the hardware
  5. Uses mnemonics such as ADD
  6. Each instruction becomes one machine code instruction
  7. Human-readable
  8. Must be translated into machine code before it runs
  9. One line can become many machine code instructions
  10. Python is an example

Exam line: Low-level = machine code and assembly. Needs translating = assembly and high-level. Only machine code runs on the CPU directly.

Computer Science · Translators

Assembler, compiler or interpreter?

Tick yes or no for every cell, then check.

Assembler
Compiler
Interpreter

Exam line: A compiler makes an executable file that runs without the original code. An interpreter makes none, so it's needed every time.

Computer Science · What the CPU really runs

What actually reaches the CPU?

You've just written a short program in Python and pressed run. Four classmates explain what happens next.

Which one is closest to what you think?
How sure are you?

Exam line: A high-level program must be translated into machine code for the particular CPU before it can run.

Computer Science · Why low-level code survives

Would you write a device driver in a low-level language?

The claim

A low-level language is the right choice for writing a device driver.

Place each piece of evidence to load the balance. Mark the strong ones — they count double.

  1. Low-level code gives the programmer direct control over the hardware.

    Evidence 1: does it support or challenge the claim?
  2. It lets programmers make efficient use of limited memory and processing power.

    Evidence 2: does it support or challenge the claim?
  3. Low-level languages are used for operating systems, device drivers and embedded systems.

    Evidence 3: does it support or challenge the claim?
  4. The programmer has to manage memory and hardware details directly.

    Evidence 4: does it support or challenge the claim?
  5. Low-level code is harder to read, learn and debug than high-level code.

    Evidence 5: does it support or challenge the claim?
  6. Writing straight in machine code means entering every instruction as binary, which is very time-consuming.

    Evidence 6: does it support or challenge the claim?

Exam line: Give a benefit (direct hardware control, efficient use of limited memory and processing power) and a drawback (harder to read, learn and debug; you manage memory and hardware yourself).

Computer Science · Your turn

Write it, then mark it

(a) State two characteristics of machine code. [2 marks] (b) Explain why a machine code program written for one type of CPU may not work as intended on a different type of CPU. [2 marks] [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

Exam line: State the fact, then give the reason it matters: different CPUs have different machine code instructions, so the same binary may not do the same thing.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • Machine code is a program written in 1s and 0s: binary instructions the CPU executes directly.
  • It's the lowest-level language a computer can run. Low-level means close to the CPU, not easy or old-fashioned.
  • Different CPUs have different machine code instructions, so machine code is specific to the CPU it was written for.
  • Have a goYour mate copies a machine code program onto a computer with a different type of CPU. "Same 1s and 0s, so it's bound to work." Would you bet your lunch on it?

    Keep your lunch. It might not work as intended.

    Different CPUs have different machine code instructions, so identical binary can be a different instruction, or none, on the other CPU.

  • The first programs were typed in by hand as binary. Very time-consuming, and machine code is hard for humans to read and write.
  • Assembly language swaps the binary operation codes for short, readable mnemonics, such as ADD for 0001.
  • An assembler translates assembly into machine code. Usually one assembly instruction becomes one machine code instruction.
  • Have a goA program has 6 assembly instructions. Roughly how many machine code instructions will the assembler produce?

    6, one for each assembly instruction.

    Assembly and machine code usually have a one-to-one relationship, so the count doesn't grow when you translate.

  • The CPU runs every instruction exactly as written. It can't guess what you meant, so a wrong instruction still runs.
  • High-level languages like Python are human-readable but must be translated first, and one line can become many machine code instructions.
  • A compiler translates the whole program at once into an executable file. An interpreter translates and runs one line at a time, every run.
  • Have a goYou run your Python program today through an interpreter. Tomorrow you run it again. Do you need the interpreter again?

    Yes, every single time.

    An interpreter translates and runs one line at a time and creates no executable file, so there's nothing saved that can run without it.

  • Low-level code gives direct hardware control and efficient use of memory and processing power, but it's harder to read, learn and debug.

The big picture

Machine code is binary instructions the CPU executes directly, and it is specific to the CPU it was written for. Assembly gives its operation codes mnemonics such as ADD (0001); an assembler translates them, usually one instruction to one. High-level code such as Python must be translated by a compiler (whole program, executable file) or an interpreter (line by line, every run), and one line can become many instructions. The CPU runs whatever arrives exactly as written. Low-level code gives hardware control and efficiency, used in operating systems, device drivers and embedded systems, but is harder to read, learn and debug.

Key points

1Machine code is binary instructions the CPU executes directly; it is the lowest-level language a computer can run.
2Machine code is specific to the CPU it is written for, because different CPUs have different machine code instructions.
3Assembly language uses mnemonics (ADD for 0001); an assembler translates it, usually one assembly instruction to one machine code instruction.
4High-level code must be translated first; one line can become many machine code instructions.
5A compiler translates the whole program and makes an executable file; an interpreter translates and runs line by line and is needed every run.
6The CPU runs instructions exactly as written. Low-level code gives control and efficiency but is harder to read, learn and debug.

Worked example

Problem

Two invented CPU types, C and D, both use the left four bits of an instruction as the operation code and the right four bits as a number. On C, 0110 is the code for 'add the number'. On D, 0110 is the code for 'stop'. Both are given the machine code instruction 0110 0010. What does each CPU do, and what does this show?

⚠ Watch out

"The CPU understands my Python." It doesn't: Python must be translated into machine code first. And "it's all 1s and 0s, so any computer can run it" fails too: different CPUs have different machine code instructions. Last trap: an instruction is a code for an action, not a number.

🧠

Memory hook

The CPU does what you SAID, not what you MEANT. And everything you write has to come down the ladder to binary: Python goes down through a compiler or interpreter, ADD goes down through the assembler to 0001.

✓

Check yourself

Without scrolling up: what translates the line SUB 3, how many machine code instructions does it become, and what does the CPU do if you meant ADD 3?

Flashcards

(15)
What is machine code?
A program written in 1s and 0s (binary instructions) that the CPU can execute directly.
Where does machine code sit among programming languages?
It is the lowest-level language a computer can run.
Why is machine code specific to one CPU?
Different CPUs have different machine code instructions, so the same binary can mean something different, or nothing, on another type.
Why is machine code hard for humans to use?
It is difficult for humans to read and write.
Why was early programming so slow?
The first programs were written only in machine code, with every instruction entered by hand as binary.
What is a mnemonic in assembly language?
A short, human-readable name for an operation code, such as ADD for the binary code 0001.
What does an assembler do?
It translates assembly language into machine code.
Assembly to machine code: what is the relationship?
Usually one-to-one: each assembly instruction translates into one machine code instruction.
Which languages are low-level?
Machine code and assembly language.
How does one line of a high-level language compare when translated?
It can become many machine code instructions, with no fixed number.
What does a compiler do?
Translates a whole high-level program into machine code at once and creates an executable file that runs without the original code.
What does an interpreter do?
Translates and runs the code one line at a time; it creates no executable file and is needed every time the program runs.
What happens when a CPU meets a wrong instruction?
It runs it exactly as written. It cannot guess what the programmer meant, so the result is unexpected or wrong.
Why still program in a low-level language?
Direct control over the hardware and efficient use of limited memory and processing power: used for operating systems, device drivers and embedded systems.
What are the drawbacks of low-level languages?
You manage memory and hardware details yourself, and the code is harder to read, learn and debug than high-level code.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.