Language Translator
Language Translator
Program Translators
Riya Jacob K
Asst. Professor on contract, Dept of BCA
Academic year 2020-21
Program Translators
• Computers only understand machine code (binary), this is
an issue because programmers prefer to use a variety of
high and low-level programming languages instead.
• To get around the issue, the high-level and low-level
program code (source code) needs to pass through
a translator.
• Source code is the code that is input to a translator and
executable code is the code that is output from the
translator.
• A translator will convert the source code into machine code
(object code).
• There are 3 types of system software used for translating
the code that a programmer writes into a form that the
computer can execute(i.e, machine code)
1. Assemblers
• Assembler is a computer program which is used to translate
program written in assembly language into machine
language.
• The translated program is called as object program.
• Assembler checks each instruction for its correctness and
generates Diagnostic messages if there are mistakes in the
program.
• Various steps of assembling are:
– Input source program in assembly language through an input
device
– Use assembler to produce object program in machine language
– Execute the program
2. Compilers
• A compiler is a program that translates a program written in high
level languages to executable machine language.
• The process of transferring high level languages source program
into object code is a lengthy and complex process as compared to
assembling.
• Compilers have Diagnostic capabilities and prompt the programmer
with appropriate error message while compiling a high level
languages program.
• The corrections are to be incorporated in the program whenever
needed, and the program has to be recompiled.
• The process is repeated until the program becomes mistake free
and translated to an object code.
• Thus the job of a compiler includes the following
– To translate HLL source program to machine code.
– To trace variables in the program.
– To include linkage for subroutines.
– To allocate memory for storage of program and variables.
– To generate error messages, if there are errors in the program
3. Interpreters
• An interpreter is a program which translates statements of a program into
machine code.
• It translates only one statement of the programme at a time.
• It reads only one statement of program, again translates it and executes it
.
• Then it reads the next statement of the program again translates it and
executes it.
• In this way it proceeds further till all the statements are translated and
executed.
• on the other hand a compiler goes through the entire program and then
translates the entire program into machine codes. A compiler is 5 to 25
times faster than an interpreter
• By the compiler, the machine codes are saved permanently for future
reference.
• On the other hand the machine codes produced by interpreter are not
saved .
• An interpreter is a small program as compared to compiler
• It occupies less memory space so it can be used in a smaller system which
has a limited memory space