1. ASSEMBLER, COMPILER AND INTERPRETER
A program is a set of instructions for performing a particular task. These instructions are
just like English words. The computer interprets the instructions as 1's and 0's. A program
can be written in assembly language as well as in high-level language. This written
program is called the source program. The source program is to be converted to the
machine language, which is called an object program. A translator is required for such a
translation.
Program translator translates source code of programming language into machine
language-instruction code. Generally, computer programs are written in languages like
COBOL, C, BASIC and ASSEMBLY LANGUAGE, which should be translated into
machine language before execution. Programming language translators are classified as
follows.
Translators are as follows.
i. Assembler
ii. Compiler
iii. Interpreter
2. ASSEMBLER: An assembler translates the symbolic codes of programs of an
assembly language into machine language instructions .The symbolic language is
translated to the machine code in the ratio of one is to one symbolic instructions to one
machine code instructions. Such types of languages are called low-level languages. The
assembler programs translate the low-level language to the machine code. The translation
job is performed either manually or with a program called assembler. In hand assembly,
the programmer uses the set of instructions supplied by the manufacturer. In this case, the
hexadecimal code for the mnemonic instruction is searched from the code sheet. This
procedure is tedious and time-consuming. Alternate solution to this is the use of
assemblers. The program called assembler provides the codes of the mnemonics. This
process is fast and facilitates the user in developing the program speedily. Assembler is
software or a tool that translates Assembly language to machine code. So, an assembler is
a type of a compiler and the source code is written in Assembly language. Assembly is a
human readable language but it typically has a one to one relationship with the
corresponding machine code. Therefore an assembler is said to perform isomorphic (one
to one mapping) translation. Advanced assemblers provide additional features that
support program development and debugging processes. For example, the type of
assemblers called macro assemblers provides a macro facility.
COMPILER: Compilers are the translators, which translate all the instructions of the
program into machine codes, which can be used again and again The program, which is
to be translated, is called the source program and after translation the object code is
3. generated. The source program is input to the compiler. The object code is output for the
secondary storage device. The entire program will be read by the compiler first and
generates the object code. However, in interpreter each line is executed and object code is
provided. M-BASIC is an example of an interpreter. High-level languages such as C, C+
+ and Java compilers are employed. The compiler displays the list of errors and warnings
for the statements violating the syntax rules of the language. Compilers also have the
ability of linking subroutines of the program. In general, compiler is a computer program
that reads a program written in one language, which is called the source language, and
translates it in to another language, which is called the target language. Traditionally,
source language is a high level language such as C++ and target language is a low level
language such as Assembly language. However, there are compilers that can convert a
source program written in Assembly language and convert it to machine code or object
code. Assemblers are such tools. On the other hand, Interpreters are tools that execute
instructions written in some programming language. Interpreter can either directly
execute high level source code or translate them to intermediate code and then interpret it
or execute precompiled code.
INTERPRETER: Interpreters also come in the group of translators. It helps the user
to execute the source program with a few differences as compared to compilers. The
source program is just like English statements in both interpreters and compilers. The
interpreter generates object codes for the source program. Interpreter reads the program
line by line, whereas in compiler the entire program is read by the compiler, which then
generates the object codes. Interpreter directly executes the program from its source code.
Due to this, every time the source code should be inputted to the interpreter. In other
words, each line is converted into the object codes. It takes very less time for execution
4. because no intermediate object code is generated. An interpreter is a computer program
or a tool that executes programming instructions. An interpreter may either execute the
source code directly or converts the source to an intermediate code and execute it directly
or execute precompiled code produced by a compiler (some interpreter systems include a
compiler for this task). Languages like Perl, Python, MATLAB and Ruby are examples
of programming languages that use an intermediate code. UCSD Pascal interprets a
precompiled code. Languages like Java, BASIC and Smalltalk first compile the source to
an intermediate code called byte code and then interpret it.
Compiler V/s Interpreter V/s Assembler
Compiler
1. Compiler translates a high level language program into machine level language.
2. Translates each high level language instruction into a set of machine level instructions
3.one to much correspondence.
4. Examples are C, COBOL, Java, etc. .
Interpreter
1. Compiler translates a high level language program into machine level language.
2. It takes one statement of a high level language program, translates it into machine
language instructions and immediately executes it.
3. A one to one relationship with the corresponding machine code
4.Languages like Java, BASIC and Smalltalk first compile the source to an
intermediate code called byte code and then interpret it.
5. Assembler
1. Assembler translates a assembly language program into machine level language.
2. It takes one statement of a assembly language program, translates it into machine
language instructions and immediately executes it.
3. Typically has a one to one relationship with the corresponding machine code
6. Assembler
1. Assembler translates a assembly language program into machine level language.
2. It takes one statement of a assembly language program, translates it into machine
language instructions and immediately executes it.
3. Typically has a one to one relationship with the corresponding machine code