Topic 1.8 - Program Construction Flashcards

1
Q

What is the function of translation programs?

A

The translation program converts the high level source code into low level assembly language (or machine code) ready for execution.

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

What is the purpose of an assembler?

A

An assembler converts code written in assembly language into object code (machine code or binary) ready for execution by the computer.

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

What is the difference between a compiler and an interpreter?

A

A compiler compiles all the code in one go by converting it from high level language to a file object code before executing. (Use for publishing and all-round)
An interpreter converts each line of code into machine code one at a time before executing it. After one line has been converted, the next line can be translated. (Usually used for debugging and testing)

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

What are the 4 stages of compilation?

A
  • Lexical Analysis
  • Syntax Analysis
  • Semantic Analysis
  • Code Generation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens during lexical analysis?

A
  • Input stream broken into tokens
  • Comments removed
  • Necessary spaces are removed
  • Error messages created if appropriate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens during syntax analysis?

A
  • A symbol table/dictionary is created
  • Tokens are checked against grammar rules (BNF)
  • If tokens are invalid, error messages are produced
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens during semantic analysis?

A
  • Checks all variables are declared and used
  • Checks that data of the appropriate data types are assigned to values declared as such data types
  • Error messages produced if necessary
  • Checks that all operations are legal (reverse polish notation is used)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens during code generation?

A
  • Machine code is generated

- Code optimisation may take place

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

What is a subprogram library?

A

This is a library which contains subprograms and subroutines. The main program can then call these subroutines from the library by importing (linking) the library.

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

What is a link loader?

A

This is a piece of software which can load parts of programs stored in different locations and link them together.

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

Name and describe two translation errors

A

Syntax error - Where code has been written outside the grammar of the language
Run-time error - e.g Trying to divide by 0 when the program is running

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