The Function and Purpose of Translators Flashcards

1
Q

Define assembly language.

A

A low level language that uses mnemonics and labels to represent a full set of instructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the assembler?

A

A piece of software that translates assembly language into machine code.
The assembler must be machine specific.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define high level language.

A

A high level language written as source code. It is understandable by the programmer often using keywords to represent instructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define machine code.

A
  • binary notation/executable form
  • set of all instructions available
  • (instructions operate on) bytes of data
  • dependent on architecture/processor design
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an interpreter?

A

A translator program that translates source code one line at a time into machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an interpreter useful for and why?

A

Debugging and testing as it returns accurate error messages as they arrive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a compiler?

A

A translator program that translates the source code as a unit into machine code to produce an executable program file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of intermediate code?

A
  • It can run on a variety of machines using an interpreter
  • Improves portability
  • Allows sections of programs to be written in different languages
  • Used in a virtual machine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What additional software is needed to run the intermediate code?

A

An interpreter/ Virtual Machine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the main purpose of a translator?

A
  • To translate source code into object code

- To detect and report any errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the disadvantages of using intermediate code?

A
  • program runs more slowly
  • has to be translated each time program is run
  • needs additional software
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does optimisation do?

A
  • make code as efficient as possible
  • increases processing speed
  • reduces the number of instructions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the features of an interpreter?

A
  • translates one line at a time
  • runs each line before translation of next
  • reports one error at a time and then stops
  • indicates the position of the error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the disadvantages of using an interpreter?

A
  • Program runs more slowly due to translation each time

- Additional software is needed every time the program is run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the advantages of using a compiler?

A
  • Protects programs from malicious use
  • Optimisation improves program speed
  • Compiler is no longer needed once executable file is produced.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe the steps an assembler performs when producing machine code.

A
  • reserves storage for instructions & data
  • replaces mnemonic opcodes by machine codes
  • replaces symbolic addresses by numeric addresses
  • creates symbol table…
  • …to match labels & addresses
  • checks syntax/gives error diagnostics
17
Q

Why are library routines used?

A
  • to perform common tasks
  • they are error-free/have been tested
  • ready to use/saves work/saves time
  • may be used multiple times
  • may have been written in different source language
  • use other programmers’ expertise
18
Q

What are the stages of compilation?

A
  • syntax analysis
  • lexical analysis
  • code generation
19
Q

What happens during syntax analysis?

A
  • accepts output from lexical analysis
  • statements/arithmetic expressions/tokens are checked…
  • …against the rules of the language/valid example given eg matching brackets
  • errors are reported as a list (at the end of compilation)
  • diagnostics may be given
  • (if no errors) code is passed to code generation
  • further detail is added to the symbol table…
  • …eg data type /scope/address
20
Q

Explain the term intermediate code and its use.

A
  • simplified code / partly translated code…
  • …which can be run on any computer/virtual machine/improves portability…
  • …using an interpreter
  • sections of program can be written in different languages
  • runs more slowly than executable code
21
Q

What software is used to convert source code into object code?

A

translator

22
Q

Explain the term source code.

A
  • the original code/code written by the programmer…
  • …often in a high level language
  • may be in assembly language
  • source code can be understood by people…
  • …but cannot be executed (until translated)
23
Q

What is a library routine?

A
  • routines are pieces of software…
  • …which perform common tasks…
  • …such as sorting/searching
  • routines are compiled
24
Q

How are library routines used?

A
  • linker is used…
  • …to link routine with program
  • loader handles addresses…
  • …when program is to be run
25
Q

Describe code generation.

A
  • Occurs after syntax analysis/is last phase of
    compilation
  • Produces machine code program/executable
    code/intermediate code…
  • …which is equivalent to the source program
  • Variables/constants are given addresses
  • Relative addresses are calculated.
26
Q

Describe optimisation.

A
  • Makes code as efficient as possible
  • Increases processing speed
  • Number of instructions is reduced