4.4 - Programming Language Translators Flashcards
What does an assembler do?
Translates assembly language into machine code
One assembly code instruction into one machine code instruction
What is source code?
The input code for the assembler
What is object code?
The output produced by the assembler
Can be saved and run whenever needed
What are the uses of assembly code?
Used when a program needs to execute as fast as possible, occupy as little space as possible or manipulate individual bits and bytes
Object code rather than source code is saved
What is the input and output for compilers?
Input = source code
Output = object code (executable machine code)
What are the phases a compiler goes through?
- lexical analysis
- syntactic analysis
- semantic analysis
What is the compilation process of compilers?
- produces intermediate code, optimises it then generates machine code
- won’t generate any machine code if there are errors
What is relocatable code?
Code produced when any errors in the code are corrected
Advantages of a compiler?
- once program is compiled, object code can be distributed and compiler isn’t needed
- object code runs faster than interpreted code
- object code is more secure as machine code cannot be easily read or copied by someone wishing to modify the code and sell it as their own
What does an interpreter do?
Translates high-level instructions into intermediate form, which it then executes
No object code is produced
Scans through a program and reports syntax errors
Advantages of an interpreter?
- useful in education as students can program interactively
- useful during development when a programmer wants to test a small piece of code without compiling the whole program
- available for high level code
What is byte code?
The intermediate form of source code is compiled into by Java compilers
Are byte code files portable?
It is as computers that run Java have a JVM that understands bytecode and converts it into machine code
How does bytecode work?
Text editor takes the source code
Compiles it into intermediate code
Then this is interpreted/compiled into machine code
Can intermediate code be transferred between JVM’s?
Yes it can be moved unchanged to another platform