GCSE Revision Aid: This resource is designed to support your revision and may contain errors. If you find a discrepancy with your class teaching, your teacher is correct — please let us know at gcserevise@scott.scottrix.co.uk.

CS26: Programming Languages & Translators

Foundation Higher AQAEdexcelOCREduqasCCEA Computer Systems

Machine code, assembly language, high-level languages, and the translators that convert between them.

Fastmail

📋 Levels of Programming Languages

Key Concept: Programming languages exist at different levels of abstraction from the hardware. Low-level languages are close to what the CPU understands. High-level languages are closer to human language and abstract away hardware details.

There are three main levels of programming language:

🔢 Machine Code

Definition: Machine code is the fundamental language of the computer, consisting entirely of binary (0s and 1s). It is the only language the CPU can execute directly without translation.
Example

A machine code instruction might look like: 10110000 01100001

The first byte (10110000) is the opcode - it tells the CPU to move data. The second byte (01100001) is the operand - the value 97 in decimal. Together, this instruction means "move the value 97 into a register."

⚙️ Assembly Language

Definition: Assembly language is a low-level programming language that uses mnemonics (short, memorable codes) to represent machine code instructions. Each mnemonic corresponds to exactly one machine code instruction.
Common Mnemonics
Mnemonic Meaning Description
MOV Move Copies a value to a register or memory location
ADD Add Adds a value to a register
SUB Subtract Subtracts a value from a register
CMP Compare Compares two values and sets flags
JMP Jump Jumps to another instruction (unconditional)
JE Jump if Equal Jumps if the previous comparison was equal
LD Load Loads data from memory into a register
ST Store Stores data from a register into memory

🌐 High-Level Languages

Definition: High-level languages are programming languages designed to be easy for humans to read and write. They use English-like keywords and abstract away hardware details like memory addresses and registers.
Examples of High-Level Languages

Python: print("Hello World")

Java: System.out.println("Hello World");

C#: Console.WriteLine("Hello World");

Each of these simple one-line statements might translate to dozens of machine code instructions. The high-level language hides this complexity from the programmer.

⚖️ Comparing Language Levels

Property Machine Code Assembly Language High-Level Language
Format Binary (0s and 1s) Mnemonics (MOV, ADD) English-like statements
Translation needed None (CPU executes directly) Assembler Compiler or interpreter
Portability Not portable (CPU-specific) Not portable (CPU-specific) Portable (with recompilation)
Ease of reading Very difficult Difficult Easy
Ease of writing Very difficult Moderate Easy
Debugging Very difficult Difficult Easier
Execution speed Fastest Fast Slower (translation overhead)
Hardware control Direct, complete control Direct, complete control Limited (abstracted)
Lines of code for same task Most Many Fewest

🔄 Translators

Definition: A translator is a program that converts code written in one programming language into another. The three types are: compiler, interpreter, and assembler.

Compiler

A compiler translates the entire source code of a high-level language into machine code all at once, creating an executable file.

Interpreter

An interpreter translates and executes source code one line at a time, without creating a separate executable file.

Assembler

An assembler translates assembly language (mnemonics) into machine code (binary).

Translator Summary:
Compiler: All source code → Machine code (executable) → Run
Interpreter: Source code line 1 → Execute → Source code line 2 → Execute → ...
Assembler: Assembly mnemonics → Machine code (object file) → Run

📊 Compiler vs Interpreter

Property Compiler Interpreter
Translation All at once, before running One line at a time, during running
Output Creates executable file No executable file created
Execution speed Fast (already translated) Slow (translating while running)
Error detection Before running (compile time) During running (runtime)
Distribution Share executable (source hidden) Must share source code
Debugging Harder (error in compiled output) Easier (errors found at exact line)
Re-running No recompilation needed Must re-interpret every time
Platform dependence Executable is platform-specific Source code is platform-independent
Examples C, C++, Java (to bytecode) Python, JavaScript, Ruby
Note: Some languages use both. Java is first compiled to bytecode, then the bytecode is interpreted by the Java Virtual Machine (JVM). This gives some of the advantages of both approaches.

🤔 When to Use Each Translator

Scenario Best Translator Why
Developing a commercial application Compiler Creates fast executable; source code is protected
Learning to program / debugging Interpreter Immediate feedback; errors found at exact line
Writing device drivers Assembler Need direct hardware control and speed
Web development (client-side) Interpreter JavaScript is interpreted in the browser
Embedded systems Assembler / Compiler Need speed and hardware control; limited resources
Rapid prototyping Interpreter Quick testing and modification without recompilation

⚠️ Common Mistakes to Avoid

Mistake Why It's Wrong How to Fix It
Saying "compilers are faster" Compilation is slow; execution of compiled code is fast Be precise: compiled CODE runs faster
Saying "interpreters find errors before running" Interpreters find errors during execution (runtime) Compilers find errors before running; interpreters during
Confusing assembler with assembly language Assembly language IS a language; assembler IS a translator Assembly = language; Assembler = translator program
Saying all high-level languages use compilers Some use interpreters (Python, JavaScript) Match the language to its typical translator

❓ Practice Questions

Q1: Explain the difference between machine code and assembly language.

Q2: Compare a compiler and an interpreter in terms of how they translate code and when they find errors.

Q3: Why might a programmer choose to write in assembly language instead of a high-level language?

Q4: What is the role of an assembler?

Q5: Give two advantages and two disadvantages of using a high-level language compared to assembly language.

✅ Answers

  1. Machine code is binary (0s and 1s) that the CPU executes directly. Assembly language uses mnemonics (short text codes like MOV, ADD) that are easier for humans to read. Each mnemonic corresponds to one machine code instruction. Assembly must be translated by an assembler.
  2. A compiler translates all source code into machine code at once, creating an executable. It finds syntax errors during compilation (before running). An interpreter translates and executes one line at a time. It finds errors at runtime (while the program is running).
  3. To have direct control over hardware (registers, memory addresses), to write very fast-executing code, or to write code for embedded systems with limited resources where high-level languages may be too resource-heavy.
  4. An assembler is a translator program that converts assembly language code (mnemonics) into machine code (binary). It performs a one-to-one translation where each mnemonic becomes one machine code instruction.
  5. Advantages: easier to read/write/debug, portable across different platforms, one statement does more work (fewer lines needed). Disadvantages: slower execution (needs translation), less direct hardware control, the programmer doesn't control exactly what the CPU does.

🎯 Exam Tips

⚠️ Common Errors

✗ Thinking assembly language is the same as machine code ✓ Assembly language uses mnemonics (ADD, MOV, LDR) which are human-readable. Machine code is pure binary (1s and 0s) that the CPU executes directly.

✗ Believing high-level languages are always better than low-level languages ✓ High-level languages are easier to write and portable, but low-level languages give direct hardware control and can be more efficient for specific tasks like device drivers.

✗ Confusing assembly language mnemonics with high-level language commands ✓ Assembly mnemonics (LDR, STR, ADD, MOV) correspond to single CPU instructions. High-level commands (print, if, for) may translate to many machine code instructions.

✗ Forgetting that all code must eventually become machine code to execute ✓ Regardless of whether you write in Python, Java, or assembly, the CPU can only execute machine code (binary). Every language must be translated to machine code at some point.

✍️ Model Answer

Full-Mark Response

Compare high-level and low-level programming languages, giving two advantages of each. Explain why a device driver might be written in a low-level language. [5 marks]

High-level languages (e.g. Python, Java): Advantage 1: Easier to read, write and debug because they use English-like commands Advantage 2: Portable — code can run on different hardware architectures with minimal changes Low-level languages (e.g. assembly): Advantage 1: Direct hardware control — can access specific memory addresses and CPU registers Advantage 2: More efficient — produces faster, more compact code with no unnecessary instructions A device driver would be written in a low-level language because it needs direct access to hardware components (ports, registers, memory-mapped I/O). High-level languages abstract away these hardware details, making them unsuitable for the precise, hardware-specific operations a driver must perform. Low-level code ensures the driver can communicate with the device at the register level.

📊 AO Deep Dive

Assessment Objective Analysis

AO1 (Computational Thinking — 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including programming languages and translators: compilers and interpreters for AQA 8525, OCR J277 & Edexcel 1CP2.

AO2 (Application — 40%): Apply knowledge and understanding of computer science, including programming languages and translators: compilers and interpreters to analyse problems in computational terms and to design, write and evaluate solutions.

AO3 (Evaluation — 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including programming languages and translators: compilers and interpreters, and make reasoned judgements about trade-offs.

📝 Exam Technique

GCSE Computer Science Exam Tips:
High-level: English-like, portable, one-to-many translation, easier debugging. Low-level: hardware-specific, faster execution, one-to-one translation, direct memory/register access. Assembly = mnemonics, Machine code = binary. All code must become machine code to run. For comparison, use a structured table or clear paragraphs for each side. Always explain WHY for scenario-based questions.

📝 Exam Questions by Topic

🎬 Video Resources

Share this page

Ready to ace your GCSE Computer Science exams?

Get the best revision books and guides to boost your grades.