Loading…
Loading…
Loading…
AQA GCSE Computer Science · 8525
AQA 8525 Check the specification (PDF) (opens in a new tab)
A processor executes machine code: instructions encoded in binary. A programmer usually writes source code in a more readable language. An assembler, compiler or interpreter bridges the gap between those written instructions and the operations performed by the processor, but they do not all work in the same way.
The important distinction is between producing machine code for later execution and carrying out source-code statements as the program runs.
Assembly language is a low-level language. It uses short mnemonic names to represent machine instructions, rather than requiring the programmer to write those instructions in binary.
An assembler translates assembly language directly into machine code. Each line containing an assembly-language instruction is assembled into one machine-code instruction. This one-to-one relationship reflects how closely assembly language matches the processor's instructions.
For example, an assembly-language instruction telling the processor to perform an addition becomes the corresponding machine-code instruction. The assembler produces that instruction; the processor executes it when the resulting program runs. Translation and execution are separate stages.
A compiler takes a high-level program and translates the whole program directly into machine code before execution. The resulting compiled program can then run without the compiler being present.
Unlike assembly language, high-level code does not have a one-to-one relationship with machine instructions. A single high-level statement can describe a task that needs several machine-code instructions to carry out.
For example, a statement that calculates a value and displays it may require several processor operations. The compiler produces the machine code needed for those operations as part of translating the program. It does not execute each source statement immediately after translating it.
If the programmer changes the source code, it must be compiled again for those changes to appear in the compiled program.
An interpreter works through high-level source code one statement at a time, carrying out each statement before moving on to the next statement to be executed. Interpretation and execution therefore happen together, rather than producing a separate machine-code program first.
Crucially, an interpreter does not generate machine code directly. Its own code contains appropriate, already compiled machine-code subroutines: routines that perform particular tasks. When the interpreter encounters a source statement, it calls the routines needed to carry it out. The processor executes those routines.
For example, when a statement requests a calculation and output, the interpreter calls suitable routines to perform those tasks. This explains how an interpreted program can run even though the interpreter does not directly turn each statement into a new machine-code instruction.
The interpreter is needed whenever the source program runs. It processes the statements again on each run, rather than leaving behind a separately compiled executable. If it encounters an error that prevents it from continuing, execution stops at that point.
Assemblers and compilers produce machine code. Interpreters call machine-code routines to carry out source statements.
The two translation routes produce machine code from the input program. The interpretation route instead uses machine code already within the interpreter to carry out the source statements.
| Translator | Input | Operation |
|---|---|---|
| Assembler | Assembly language | Translates directly into machine code; one assembly instruction becomes one machine-code instruction. |
| Compiler | High-level source code | Translates the whole program directly into machine code before execution. |
| Interpreter | High-level source code | Carries out statements one at a time by calling machine-code subroutines within its own code. |
For an operational comparison, explain what each translator takes as input, what it produces and when execution happens.
Do not say that an interpreter directly produces machine code one line at a time. It carries out statements by calling appropriate machine-code subroutines within its own code.
The one-to-one relationship is between an assembly-language instruction and a machine-code instruction, not between a high-level statement and a machine-code instruction.
It can see this note and what your specification asks for.
Answers are free with an account.
1 free note left this week
Get more free notesYour answer sets when this note comes back for review, or marks it complete.
Was this note helpful?
Log in to tell us whether it helped, or to report a problem.
Last updated
Source code
The program instructions written by a programmer, before translation or interpretation.
Machine code
Instructions encoded in binary that a processor can execute directly.
High-level language
A programming language that expresses operations using statements rather than processor-specific machine instructions.
Assembly language
A low-level programming language that uses mnemonic names to represent machine-code instructions.
Assembler
A program that translates assembly language directly into machine code, with each assembly-language instruction becoming one machine-code instruction.
Compiler
A program that translates a whole high-level program directly into machine code before that program is executed.
Interpreter
A program that carries out high-level source-code statements one at a time by calling appropriate machine-code subroutines within its own code, rather than generating machine code directly.
Subroutine
A routine within a program that can be called to perform a particular task.
Put your knowledge into practice — try past paper questions for Computer Science
Source code
The program instructions written by a programmer, before translation or interpretation.
Machine code
Instructions encoded in binary that a processor can execute directly.
High-level language
A programming language that expresses operations using statements rather than processor-specific machine instructions.
Assembly language
A low-level programming language that uses mnemonic names to represent machine-code instructions.
Assembler
A program that translates assembly language directly into machine code, with each assembly-language instruction becoming one machine-code instruction.
Compiler
A program that translates a whole high-level program directly into machine code before that program is executed.
Interpreter
A program that carries out high-level source-code statements one at a time by calling appropriate machine-code subroutines within its own code, rather than generating machine code directly.
Subroutine
A routine within a program that can be called to perform a particular task.