Monday, April 28, 2014

Computer (C 3.2): The functions and purposes of translators

The functions and purposes of translators


  • Machine code is the set of instructions or operations, in binary, that a computer's processor uses.
  • Assembly language is a set of mnemonics that match machine code instructions.
  • An assembler is software which translates an assembly language program into machine code.

    • An assembler looks up an assembly language mnemonic in a table and reads off the matching machine code instruction.

  • Interpretation involves software that reads one source code instruction, interprets it and executes it before moving onto the next instruction.
  • Compilation involves software that reads a complete source code program, analyses it and produces object code. The object code is executed without reference to the source code, at a later time (or even on a different computer).

    • During lexical analysis, the source code is checked and turned into a stream of tokens. Errors in the use of the language (such as misspelled keywords or incorrectly formed identifiers) are reported.
    • During syntax analysis, the output from the lexical analyser is checked against the grammar of the programming language. Errors in the use of the language (such as missing keywords) are reported.
    • In the code generation phase, the output from the syntax analyser is turned into optimised object code.
    • Optimisation tries to improve the code so that it takes as little processing time and memory as possible.

  • A library routine is a precompiled, self-contained piece of code that can be used in the development of other programs.
  • A loader loads modules (including library routines) into memory and sorts out memory allocations.
  • A linker links modules together by making sure that references from one module to another are correct.
  • Errors recognised during compilation (by the syntax and lexical analyser) are reported to the programmer, who must fix them before recompiling.

No comments:

Post a Comment

Preeti to Unicode Converter