F453 - functions and purpose of translators Flashcards

1
Q

Describe assembly language

A

a language related closely to the computer being programmed/low level language/machine specific
uses descriptive names (for data stores)
uses mnemonics (for instructions)
uses labels to allow selection
each instruction is generally translated into one machine code instruction may use macros

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

Describe machine code

A

binary notation
set of all instructions available
to the architecture/which depend on the hardware design of the processor instructions operate on bytes of data

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

What tasks are performed by the assembler when producing machine code?

A

reserves storage for instructions and data
replaces mnemonic opcodes by machine codes
replaces symbolic addresses by numeric addresses
creates symbol table to match labels to addresses
checks syntax/offers diagnostics for errors

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

What are the features of the interpreter?

A

translates one line/statement…
…then allows it to be run before translation of next line reports one error at a time…
…nd stops

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

What are the features of a compiler?

A

translates the whole program as a unit

creates an executable program/intermediate program may report a number of errors at the same time optimisation

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

Describe lexical analysis

A

source program is used as the input
tokens are created from individual symbols and from…
…he reserved words in the program
a token is a fixed length string of binary digits
variable names are loaded into a look-up table / symbol table redundant characters (eg spaces) are removed
comments are removed
error diagnostics are given
prepares code for syntax analysis

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

What is the purpose of a translator?

A

convert from source code… …to object code

detect errors in source code

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

Why may intermediate code may be more useful than executable code?

A

can run on a variety of computers
same intermediate code can be obtained from different high level languages
improves portability

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

What additional software is needed to run intermediate code?

A

interpreter / virtual machine

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

What is a disadvantage of using intermediate code?

A

the program runs more slowly/has to be translated each time it is run / need additional software

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

What does code optimisation do?

A

makes code as efficient as possible increases processing speed reduces number of instructions

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

Describe 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

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

What’s intermediate code, and it’s 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

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

What software converts source code into object code?

A

translator

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

What is 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)

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

Why might library routines help programmers, and when are they used

A

Library routines:
routines are pieces of software… …which perform common tasks… …such as sorting/searching routines are compiled
Why library routines help programmers:
routines are error-free/have already been tested already available/ready to use/saves work/saves time routines may be used multiple times
routines may have been written in a different source language
allows programmer to use others’ expertise
How routines are used:
linker is used…
…to link routine with program
loader handles addresses…
…when program is to be run