Multiple choiceQuestion 1 · Recall
Loading…
By the end you can say why each of the three translators is needed, and what each one produces.
A processor executes machine code — binary instructions. Nobody wants to write thousands of binary numbers, so we write in a form we can read and let software do the translation.
| Source language | Translator | Output |
|---|---|---|
| Assembly language | Assembler | Machine code (object code) |
| High-level language | Compiler | Machine code (object code), saved as an executable |
| High-level language | Interpreter | Nothing saved — the program is translated and executed statement by statement |
All three exist for one reason: the processor cannot run anything else.
An assembler translates an assembly language program into machine code.
Assembly language uses mnemonics such as LDR, ADD and STR instead of binary, and labels instead of addresses. Each mnemonic maps to one machine instruction, so the translation is close to one-to-one.
The assembler's jobs:
Why bother with assembly at all? It gives precise control of the hardware and produces very efficient code — useful for device drivers and embedded systems.
A compiler translates a whole high-level program into machine code before it runs. The output is an executable file you can run again and again without the compiler.
An interpreter translates and executes the program one statement at a time while it runs. Nothing permanent is produced: every run needs the interpreter again.
Both check for errors, but at different moments: