Machine code
Machine code is expressed in binary and is the only language a processor can execute directly.
Each type of processor has its own specific machine code instruction set — the complete list of operations that processor understands, each with its own binary pattern. A program compiled for one processor family will not run on a different one.
1110 0101 1001 1111 0000 0000 0001 0100
That is one instruction. Writing a program this way is possible but agonisingly slow and almost impossible to debug.
Assembly language
Assembly language replaces the binary patterns with short mnemonics that a human can read:
LDR R1, price ; load price into register 1
LDR R2, quantity ; load quantity into register 2
MUL R3, R1, R2 ; multiply them
STR R3, total ; store the result
Assembly language has a 1:1 correspondence with machine code. Each line of assembly language is assembled into a single machine code instruction. This is the single most examined fact in 3.4.4.
The differences between them
| Machine code | Assembly language |
|---|
| Written as | Binary | Mnemonics (LDR, ADD, STR) |
| Human readable? | Effectively no | Yes, with effort |
| Needs translating? | No — executed directly | Yes — by an assembler |
| Relationship | — | 1:1 with machine code |
| Processor specific? | Yes | Yes |
Where assembly is actually used
The specification is specific: assembly language is often used to develop software for embedded systems and for controlling specific hardware components.
Why there in particular?
- Embedded systems often have very limited memory and processing power, so the efficiency of hand-written low-level code matters.
- Device drivers and hardware control need direct access to specific hardware features that a high-level language may not expose.
- Real-time systems need precisely predictable timing, which low-level control makes possible.
AQA tip. Both machine code and assembly language are low-level. A question asking "name two low-level languages" wants exactly these two.