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 42 ADD 33 SUB 34 STORE
| machine code | running total | stored |
|---|---|---|
| 0011 0100 | 4 | - |
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.
Press Next to run one instruction at a time. Watch the machine code column fill in beside each readable line.
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
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?
Where does machine code sit among programming languages?
Why is machine code specific to one CPU?
Why is machine code hard for humans to use?
Why was early programming so slow?
What is a mnemonic in assembly language?
What does an assembler do?
Assembly to machine code: what is the relationship?
Which languages are low-level?
How does one line of a high-level language compare when translated?
What does a compiler do?
What does an interpreter do?
What happens when a CPU meets a wrong instruction?
Why still program in a low-level language?
What are the drawbacks of low-level languages?
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 postedMore AQA GCSE Computer Science topics
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.