Programming Languages and Translators
Software
A low-level language is one where each instruction maps directly or very closely to a single machine-code instruction, and where the programmer has direct control over the computer's hardware (registers, memory addresses, processor instructions).
There are two low-level languages to know: and .
Machine code (1st generation)
Machine code is the raw binary language the CPU runs directly. Every instruction is a string of 1s and 0s that matches one specific operation in the CPU's instruction set.
A machine-code instruction might look like 10110111 00000101, which is meaningless to a human reader, but the CPU can execute it without any translation step.
- Directly executed by the processor.
- Specific to one CPU architecture. Machine code for an Intel x86 chip will not run on an ARM chip.
- Almost impossible to write by hand for any non-trivial program.
Assembly language (2nd generation)
Assembly language is a low-level language where each binary machine-code instruction is replaced with a short, human-readable abbreviation called a .
Typical assembly mnemonics:
| Mnemonic | Meaning |
|---|---|
| LDA | Load: copy a value from memory into the accumulator |
| STA | Store: copy the accumulator's value into a memory location |
| ADD | Add a value to the accumulator |
| SUB | Subtract a value from the accumulator |
| JMP | Jump to a different instruction |
| HLT | Halt the program |
Assembly is far easier for humans to write than raw machine code, but it is still one-to-one with machine code: each assembly instruction translates to exactly one machine-code instruction.
Before assembly can run, it must be translated into machine code by a piece of software called an (covered in section 4).
Why use a low-level language?
Modern programmers rarely write entire programs in assembly, but low-level code is still used for specific situations:
- When direct hardware control is needed (writing a device driver, programming a microcontroller, talking to specific CPU registers).
- When maximum speed is needed in a small section of code (game engines, signal processing).
- When memory is very tight (embedded systems, boot loaders, small microcontrollers).
- When the code is specific to a particular CPU anyway, so machine dependence is not a problem.
Advantages and disadvantages of low-level languages
| Advantages | Disadvantages |
|---|---|
| Direct control of memory, registers and hardware | Hard to read and write for humans |
| Efficient: small memory footprint, very fast execution | Machine-dependent: code only runs on one CPU architecture |
| Predictable timing (useful in real-time systems) | Easy to make mistakes that crash the system |
| Slow to develop compared to high-level languages |
Exam tip
Giving a benefit of assembly language
A one-mark question that asks for a benefit to the programmer of writing a program in assembly language wants a strength that only low-level code has. The mark scheme credits any one of: faster execution than a high-level program, more control over manipulating the hardware, or the use of machine-specific instructions. Ease of reading and writing, and being machine independent, are the strengths of high-level languages, so keep each property attached to its own level: the same low-level strengths turn up as the wrong options when a multiple-choice question asks for a benefit of a high-level language.
Quick check
4 short questions on this note. See what has stuck, and where to look if something hasn't.