(2) Function and purpose of translators

¡Supera tus tareas y exámenes ahora con Quizwiz!

State what additional software is needed to run the intermediate code? (1)

An interpreter / Virtual machine

Describe the term machine code (2)

Binary Notation\nSet of all instructions available\n.. for the architecture/ which depend on the hardware design of the processor\nInstructions operate on bytes of data

Some compilers produce intermediate code instead of executable code. Explain why intermediate code may be more useful than executable code (2)

Can run on a variety of computers\nSame intermediate code can be obtained from different high level languages\nImproves portability

What is intermediate code?

Code that has been translated, usually by a compiler ... into code that needs to be further translated( usually interpreted) before it can be run

What does the linker do?

Combines modules/ Library routines ... That are already compiled ( are in object code)

Various types of translator may be used when writing and preparing a new computer Program. Explain the main purpose of a translator (2)

Convert from source code ... To object code\nDetect errors in source code

What does the loader do?

Copies modules into memory ... From backing store ... Ready for execution Completes address links to the program

Some compilers produce intermediate code for a virtual machine. Explain two advantages of using intermediate code. (2)

Intermediate code is platform independent/ may be used on a variety of machines\nIntermediate code program has been compiled so is error-free

How Library routines are used

Liker is used\n... to link routine with program\nLoader handles addresses\n... When program is to be run

What is object code?

Low level/ machine code/ Binary code ... used by the computer Produced by the translator

Describe two differences between machine code and assembly language (4)

Machine code is written in binary/hex whereas assembly language:\nIs written in plain text\nincludes mnemonics \nincludes names for data\nMachine code needs no translation\nMachine code is very difficult to write

When a compiler is used to produce executable code, code generation includes optimisation. Describe what optimisation does. (2)

Makes code as efficient as possible\nIncreases Processing speed\nReduces number of instructions

Describe how library routines are used when producing software (3)

May allow programmer to use code which was written in a different language\nLinker is used to link the routine to the program\nStandard routines for sorting/ searching available\nstandard routines for sorting/searching available

Features of High level Language

May use local variables\nNeeds translation before the program can be executed\nMay be translated into intermediate code

What is source code?

A Program written in a high level language (or in assembler) ... by the user Easy for people to understand It cannot run until it has been ... Translated by the translator(compiler/ interpreter/ assembler) to object code

What is executable code?

A complete program ... That the computer can run ... Without further translation Now in machine code

Languages used in computing include assembly language and machine code. Describe the term assembly language (2)

A language related closely to the computer being programmed/ Low level/ Machine specific\nUses descriptive names (for data stores)\nUses mnemonics (for instructions)\nUses labels to allow selection\nEach instruction is generally translated into one machine code instructions\nMay use Macros

Explain the meaning of the term virtual machine and how intermediate code is run on it (2)

A virtual machine is a generalised computer on which the program can run\nIntermediate code is run using an interpreter (for the specific computer)

Describe what happens during syntax analysis (5)

Accepts outputs from lexical analysis\nStatements/arithmetic expressions/tokens are checked\n... Against the rules of the language/ Valid example given\nErrors are reported as a list ( End of compilation)\nDiagnostics may be given

Name the three stages of compilation

Syntax analysis\nLexical analysis\nCode generation

Explain the term source code. (4)

The original code / Code written by the programmer\n... Often in a high level language\nMay be in assembly language\nSource code can be understood by people\n... but cannot be executed ( until translated)

State one disadvantage of using intermediate code. (1)

The program runs more slowly\nHas to be translated each time it is run\nNeeds additional software to be run

State three of the tasks performed by an assembler when producing machine code (3)

Translates a program from A/L to M/C\nOne assemble language instruction is changed into one machine code instruction\nReserves storage for instructions and data\nReplaces mnemonic opcodes by machine code\nReplaces symbolic addresses by numeric addr.\nCreates symbol table to match labels to addr.\nChecks Syntax/ offers diagnostics for errors

Either a interpreter or a compiler may be used with a high level language program Describe one feature of an interpreter. (2)

Translates one line/ Statement\n... Then allows it to be run before translation of next line\nReports one error at a time\n... and stops

State two features of a compiler (2)

Translates the whole program as a unit\nCreates an executable program/ intermediate program\nMay report a number of errors at the same time\nOptimisation

Describe what is meant by a library routine and their use when producing programs (4)

Piece of software\nRoutines often perform common tasks\nRoutines are compiled\nRoutines are error-free\nAvailable to programmer to use with a new program

What are Library routines

Pieces of software\n... which perform common tasks\n... Such as sorting/searching \nroutines are compiled

Describe what happens during lexical analysis (8)

Points to be made:\nSource program is used as the imput\nTokens are created from individual symbols and from ... the reserved words\nA token is a fixed length string of binary digits\nVariable names are loaded into a look-up table\nRedundant characters (and comments) are removed

Why Library routines help programmers

Routines are error-free/ Have already been tested\nAlready available/ Ready to used/ saves work/time\nMay be used multiple times\nMay have been written in a different source language\nAllows programmer to use anothers expertise

Some compilers produce intermediate code. Explain the term intermediate code and its use. (3)

Simplified code / Partly translated code\n... which can be run on any computer/ VM\n... Using an interpreter\nSections of program can be written in different languages\nRuns more slowly than executable code

Software is used to convert source code into object code. Name this type of software (1)

Translator

Features of Assembly language

Uses Mnemonics\nMay use relative addresses\nNeeds translation before the program can be executed


Conjuntos de estudio relacionados

Anatomy and Physiology 2 Cumulative Final 1-50

View Set

2016 BEHAVIORAL OBSERVATION AND SCREENING

View Set

Behavioral Health Lecture 5- Personality Disorders and Substance Abuse .

View Set

ap bio topic 2: the cell questions

View Set