F453 Translators

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Virtual machine (2)

A theoretical computer which provides an environment in which a translator is available. An interpreter is used to translate the intermediate code.

Advantages of library routines (5)

As they are compiled they can generally be considered tested and error-free. Already available saves working having to develop similar routines. Routines may be used multiple times in multiple programs. Library routines may have been written in a different source language. Allows programmer's to use other's expertise.

Linker (2)

Combines modules / library routines ... ... that are already compiled.

Comparing compilation and interpretation (6)

Compilation is much faster than interpretation. Compiled object code will run faster than the same interpreted code. Object code does not need the compiler to run it, only to convert it from the source code. Interpreter software must be present on computer to interpret source code. Easier to protect intellectual property with compiled object code, as machine code is difficult to understand. If there is errors in interpretation then program stops when the error occurs. No need to re-compile. Much easier to debug and program interpreted object code than the compiled object code. Interpreters are far simpler to write than compilers. Compilers use more memory as all of the executable needs to be loaded into memory. Interpreted source code only has to be present one line at a time in memory.

Executable code (2)

Contains the machine code of the software. The machine code runs on the CPU when the executable file is loaded into main memory.

Translator (2)

Converts source code to object code. Identifies errors in the source code.

Loader (2)

Copies modules from backing store into memory ready for execution. Completes address links to the program.

Intermediate code (7)

Has been translated, usually by a compiler, into code that needs to be further translated, usually by an interpreter, into object code before it can be run. Produced by a compiler. Runs on any computer. Allows portability between machines. Allows sections of code to be written in different source languages, by different programmers. Suitable for a specific task. Error free, as it has already been compiled.

Advantages of intermediate code (4)

Intermediate code is platform independent. Portable / improves portability. Has already been compiled and so is error free. Same intermediate code can be obtained from many high level languages.

How library routines are used (2)

Linker is used to link the library routine with program. Loader handles addresses when program is to be run.

Assembly language (10)

Low level language Closely related to the hardware design of the processor [Different families of processors have different assembly languages which can be used]. Instructions are represented by mnemonics, which are easily recognised by the programmer. Data locations (data stores) are given descriptive names. Allows for programmers to recognise what data can be stored in this location. Labels can be written which allow for flow control to occur (e.g. jumping to a label). May use macros, which are sequences of instructions that are assigned a name. Used anywhere in program. Each assembly instruction is generally translated into one machine code instruction. Translated by an assembler. Easier to write than machine code but more difficult than a high level language. May use addressing modes such as relative and indexed addressing.

Object code (4)

Low level machine code. Used by computer. Produced by translator. Dependent on the hardware design of the processor. Equivalent to machine code (?) Can be linked to form an executable file. (?)

Optimisation (3)

Makes the code as efficient as possible. Reduces number of instructions. Increases processor speeds. [Programmer can choose between speed and size]

Library routines (5)

Pieces of software that perform common tasks. E.g. sorting or searching procedures. Library routines are compiled. As they are compiled they can generally be considered tested and error-free. Available for programmers to use with new programs.

Advantages of executable code / file (3)

Runs very quickly when compared to interpreting each line of source code one at a time. Original source code is absent. Protects copyright. Very convenient. Making unauthorised changes to software is difficult.

Disadvantages of intermediate code (2)

Slower than a compiled executable as has to be interpreted every time it is run. Requires more software (a virtual machine).

Source code (5)

The original code that is written by the programmer. Often written in a high level language. May be written in an assembly language. Cannot be executed by a computer system until has been translated. Easier to understand than machine code / object code.

Syntax analysis (7)

The output of lexical analysis is used as the input to syntax analysis. The syntax of the program is checked. Pattern of tokens (statements) are checked against the rules of the language. Further data is entered for each item in the symbol table e.g. data-type, scope, address. Errors are reported as a list at end of compilation. Diagnostics based on the errors may be given. If there are no errors output of syntax analysis becomes input of code generation.

Lexical analysis (8)

The source program is used as input to this stage. Redundant characters, such as whitespace, are removed. Comments are removed. Tokenisation occurs. Code is parsed (analysis of all strings in code) and all keywords, symbols and reserved words in the program are replaced with tokens. Tokens are a fixed length string of binary digits. A symbol table (look-up table) and all variable names and constants are loaded into this table. Stores values of data type etc. Error diagnostics are given. Output of lexical analysis becomes input of syntax analysis, the next stage of compilation (If no errors are detected).

Tasks performed by an assembler (8)

Translates a program from assembly code to machine code. One assembly language instruction is translated into one machine code instruction. Reserves storage for instructions and data. Replaces mnemonic opcodes with machine code instructions. Replaces symbolic addresses with numeric addresses (memory locations). Creates symbol table to match addresses to labels. Checks syntax / error diagnostics are given. Produces less machine code than equivalent high level program -> runs faster.

Features of a compiler (6)

Translates program as a single unit. Creates an executable program or intermediate code. Returns a list of errors at the end of complication attempt. E.g. type error. Attempts to perform code optimisation. Compilers will attempt to produce the fastest possible machine code program. Allows source code to be independent of target processor. The same source code can be compiled into executable code that can run on different processors. Increases portability of the code. May also produce spurious errors - compiler makes assumptions about the rest of the code after detection of original error.

Features of interpreters (6)

Translates the source code one statement at a time and executes it before another statement is translated. Reports one error at a time after each line / statement is executed. Interpretation and execution stops as error is reported. Debugging is simple as each line of source code is checked for errors before it is interrupted and translated. Less memory is needed to interpret source code as only a few lines of source code need to be in memory at any one time. Runs slower than executable code because interpreter has to analyse and convert each line of source code into machine code before it can be executed. Cannot be optimised like a complier does with executable code it produces.

Machine code (6)

Written in binary or hexadecimal notation. Requires no translation. Instructions operate on bytes of data. Very difficult for a programmer to write. Set of all available instructions will depend on the hardware design of the processor. Machine code for every different family of processors is different. [Set of instructions available to architecture] Machine code is loaded into the CIR before being executed.

Code generation (6)

[Last phase of compilation] Accepts output of syntax analysis as input. Variables / constants are given addresses. Relative addresses are calculated. Produces either executable code or intermediate code. Performs optimisation. Library routines are called up and referenced.


Kaugnay na mga set ng pag-aaral

EES 101 Exam 3 Study Guide AKA my hell on earth

View Set

CHEM 2261: structures and bond Practice 2

View Set

Chapter 12: Materials Requirement Planning (MRP) and Enterprise Resource Planning (ERP)

View Set

Chapter 11 - Developmental Theories

View Set

Chapter 16 Evolution and Diversity of Plants v

View Set

Physics Final Chapter 1-3 Quizzes

View Set

Moral Dilemmas Exam 1 Study Guide

View Set

Intro to Critical Thinking and Reasoning

View Set