Program Construction Flashcards

(19 cards)

1
Q

Describe an assembler

A

A simple translation program
- converts low level assembly language into machine code
- 1 instruction = 1 machine code instruction
-no extra unnecessary lines of code
-used for maximum efficiency

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

Describe a compiler

A
  • converts high level language into machine code
  • can be run over and over once compiled
  • shows list of errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe an interpreter

A

-runs a high level language program
-doesn’t convert into a binary executable
-interprets one line, executes one line

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

Give As and Ds for a compiler

A
  • takes a while but can be run over and over
  • end user doesn’t need a compiler
    -shows a list of errors

-can be slow
-software needs to be recompiled

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

Give As and Ds for an assembler

A

+quicker bc AL is closer to machine code, doesn’t require additional steps
-difficult to write and read
-machine dependant, can only be run on a specific type of computer

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

Give As and Ds for an interpreter

A

+ as lines are run, can debug easily
+test code immediately

  • end user needs access to code, security risk
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Assuming a compiler and interpreter both exist for the language…

A

Interpreter for development
- quick testing

Compile for distribution
- int security risk

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

What is meant by intermediate language?

A

Similar to machine code
H
Not processor specific

Allows code to be created to run on multiple architectures

Code runs very quickly, conversion is straightforward

Eg. Bytecode for Java and CIL for .Net

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

What are translation errors?

A

Errors spotted by the compiler

Syntax, structure
Semantic, spotted in semantic stage
Linking, linking code

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

What are execution errors?

A

Run time errors

Occur when a program is running, cause program to crash

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

What are the stages of compilation?

A

Source Code
Lexical analysis
Syntax analysis
Semantic analysis
Code generation
Optimisation
Object code

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

Describe lexical analysis

A

-Removes comments and spaces
- tokenisation: source code to tokens, refer to symbol table
- add entries to symbol table for names
- basic error checking
-program now set of token

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

Describe syntax analysis

A

Checks structure of program is correct,
Follows grammar rules of language

List of syntax errors

Compilation may stop

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

Describe semantic analysis

A

Check for types of error:
- variables declared
-values are assigned to data type
-no illegal mixed code arithmetic

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

Describe code generation and optimisation

A

Generates machine code

Each HLL line becomes many lines of machine code

Optimisation-
Improve efficiency, make program smaller

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

Compare the translation process carried out by a compiler with the translation process carried out by an interpreter

A

Compiler-
Takes entire program as input, produces machine code version

Compiled program can be re-run without more translation

Interpreter-
Single source code instruction. Translate, execute.
Interpreter needs to be repeated each time program is run

17
Q

Describe a diagram of a compiler

A

Source code- compile- object code- run any number of times

18
Q

Describe a diagram of an interpreter

A

Source code- interpret line- execute line LOOP