Topic 14 · Notes

Program construction

These notes are part of a subscription

12 sections covering the whole specification for this topic, with worked examples.

Preview

Why programs are translated

A processor can only run machine code: binary instructions from its own instruction set. Programs are written in source code, so they must be translated first.

TermMeaning
Source codeThe program as written by the programmer, in a high-level language or assembly language
Object codeThe translated program produced by a compiler or assembler, ready to be linked
Machine codeBinary instructions the processor can run directly
TranslatorA program that turns source code into a form the computer can run: a compiler, interpreter or assembler

A compiler translates the whole high-level program in one go, before it is run. The rest of the AS part of this topic follows the stages a compiler goes through.

Also in these notes

  • The stages of compilationAS
  • Lexical analysisAS
  • The symbol tableAS
  • Syntax analysisAS
  • Semantic analysisAS
  • Code generation and optimisationAS
  • Compilers, interpreters and assemblersA2
  • How an assembler worksA2
  • Linkers, loaders and librariesA2
  • Intermediate code and virtual machinesA2
  • Translation errors and execution errorsA2