6.3 Types of program translator Flashcards
What does an assembler do?
An assembler translates assembly language into machine code. As each assembly language instruction has a 1-to-1 relationship to machine code instruction, translation between the two languages is fairly quick and straightforward. Assemblers are platform specific meaning that a different assembler must exist for each different type of processor instruction set.
What does a compiler do?
A compiler can be used to translate programs written in high-level languages into machine code. Compilers take a high-level program as their source code, check it for errors than translate the entire program at once. If the source code contains an error it will not be translated. As compilers produce machine code so they are said to be platform specific. Once translated a compiled program can be run without the requirement for any other software to be present. Unlike interpreters.
What does an interpreter do?
An interpreter translates high-level languages into machine code line-by-line. Interpreters have procedures that can be used to translate each kind of program instruction. Interpreters check for errors as they go. This means programs with errors can only be partially translates by an interpreter until the error is reached. When the program is translated by an interpreter both the program source code and the interpreter must be present. This results in poor protection of the source doe compared to compliers which make the original code difficult to extract.
Compare compilers to interpreters?
Compilers check source code for errors line-by-line before translating but in an interpreter translation begins immediately.
Compilers entire source code is translated at once but in an interpreter each line is checked for errors and then translated sequentially.
There is no need for source code or compiler to be present when the translated code is executed for compilers. With interpreters both the source code and the interpreter must be present when the program is executed.
Compilers protect the source code from extraction however interpreters offer little protection of source code.
What are intermediate languages and their process of complier and interpreter translation?
Some compilers translate source code into an intermediate language. It is commonly known as byte-code and allows for platform independence. The compiler uses a virtual machine to execute bytecode on different processors. Each different processor instruction set will have its own virtual machine.
For interpreters using intermediate languages it allows the interpreter to translate the source code just once, while still being able to execute the translated code with a variety of different processors.
What is source code and object code?
Source code is the name given to the input to a translator. A translators output is called object code and is produced from source code.