Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

UNIT 6.

COMPILERS VERSUS INTERPRETERS


Task 1. Learn the following words and word-combinations:
an assembler – a type of computer program that converts a program written in assembly language
into machine code;
to augment – додавати;
a tag – ярлик;
identifiable – упізнаваний;
relocatable – переміщуваний;
a linker – a program that adjusts two or more machine-language program segments so that they may
be simultaneously loaded and executed as a unit;
to generate – створювати;
capable – здатний;
implementing – здійснюючи;
an approach – підхід;
a parse tree – дерево [синтаксичного] разбору;
software-defined – програмно-конфігурований;
token – знак;
a stack machine – (обчислювальна) машина зі стековою організацією;
a quadruple code – чотирикратний код;
conversion – перетворення;
factored out – виносити за дужки, факторизувати;
akin – подібний до;
ample – достатній;
execution – виконання;
embedded – вмонтований.

Task 2. Read and translate the text:


Programs written in a high level language are either directly executed by some kind of
interpreter or converted into machine code by a compiler (and assembler and linker) for the CPU to
execute.
While compilers (and assemblers) generally produce machine code directly executable by
computer hardware, they can often (optionally) produce an intermediate form called object code. This
is basically the same machine specific code but augmented with a symbol table with names and tags
to make executable blocks (or modules) identifiable and relocatable. Compiled programs will
typically use building blocks (functions) kept in a library of such object code modules. A linker is
used to combine (pre-made) library files with the object file(s) of the application to form a single
executable file. The object files that are used to generate an executable file are thus often produced at
different times, and sometimes even by different languages (capable of generating the same object
format).
A simple interpreter written in a low level language (e.g. assembly) may have similar machine
code blocks implementing functions of the high level language stored, and executed when a function's
entry in a look up table points to that code. However, an interpreter written in a high level language
typically uses another approach, such as generating and then walking a parse tree, or by generating
and executing intermediate software-defined instructions, or both.
Thus, both compilers and interpreters generally turn source code (text files) into tokens, both
may (or may not) generate a parse tree, and both may generate immediate instructions (for a stack
machine, quadruple code, or by other means). The basic difference is that a compiler system,
including a (built in or separate) linker, generates a stand-alone machine code program, while an
interpreter system instead performs the actions described by the high level program.
A compiler can thus make almost all the conversions from source code semantics to the
machine level once and for all (i.e. until the program has to be changed) while an interpreter has to
do some of this conversion work every time a statement or function is executed. However, in an
efficient interpreter, much of the translation work (including analysis of types, and similar) is factored
out and done only the first time a program, module, function, or even statement, is run, thus quite
akin to how a compiler works. However, a compiled program still runs much faster, under most
circumstances, in part because compilers are designed to optimize code, and may be given ample time
for this. This is especially true for simpler high level languages without (much) dynamic data
structures, checks or typing.
In traditional compilation, the executable output of the linkers (.exe files or .dll files or a
library, see picture) is typically relocatable when run under a general operating system, much like the
object code modules are but with the difference that this relocation is done dynamically at run time,
i.e. when the program is loaded for execution. On the other hand, compiled and linked programs for
small embedded systems are typically statically allocated, often hard coded in a NOR flash memory,
as there are often no secondary storage and no operating system in this sense.
Task 3. Answer the questions:
1. What is called an object code?
2. Why is a linker used?
3. What is the difference between a compiler system and an interpreter system?
4. When is the executable output of the linkers typically relocatable?
Task 4. Match the words with their definitions or synonyms:
1. to augment – a) similar;
2. a tag – b) included;
3. identifiable – c) realizing;
4. embedded – d) a method;
5. to generate – e) enough;
6. capable – f) distinguishable;
7. implementing – g) to add;
8. an approach – h) to create;
9. а token – i) transformation;
10. conversion – j) a label;
11. akin – k) а sign;
12. ample – l) able.

You might also like