Compilers, Interpreters and Assemblers

Table of contents:

Compilers, Interpreters and Assemblers

Translators, the middle man

By now, we have come to know that a computer, or a Central Processing Unit does not understand programs written in any high-level language. A computer processor can understand a program when it is written in machine-friendly binary format consisting of 0s and 1s only. This binary format is known as the Machine language or machine code, which is the lowest level of computer languages.

So, we need some type of translator inbetween high level language and machine code that can understand what is written in high level language, and can convert it into machine code.

Table of contents:


A compiler translates a program written in high-level language into Machine language (machine code). It itself is a special computer program that understands both the high-level language and the machine language.

• Function of a Compiler Begin End Programmer writes program rectifies errors High-level program Machine code requests compilation analyzing ... Stops compilation Errors at lines 4, 7 are reported to programmer No error: all clear ... Compilation initiates ... Compiler This process is repeated until all the errors are rectified by the programmer. Compilation process is initiated to create an executable file consisting of machine codes. The executable file created by a compiler is stored in the disk. Generally, it carries an extension .exe. This independent file can be executed any time without further requirement of compilation. Even the source file is not required to execute this file.

Once a program is written in any high level language, the programmer raises a compilation request. Then the compiler scans the whole source program and analyses the instructions in depth. If there are errors, details like error-line-no., error-type etc. are reported to the programmer for rectification. The actual compilation does not happen until the source program becomes completely error-free.

When the source program becomes completely error-free, compilation process is initiated. An executable file, containing machine codes, is created, and executed for the desired output. This executable program can be executed whenever it is required. This whole process is known as compilation.


An interpreter does the similar job, but in a different way. It is a program which reads and analyses an instruction from a high-level program, translates it into machine code, and immediately executes the instruction. Then it repeats with the next instruction.

• Function of an Interpreter Begin End Programmer writes program rectifies error High-level program requests execution analyse, interpret, execute Stops interpretation Error at line 8 is reported to programmer Interpretation and Execution complete... When an error is found, interpretation stops immediately, and error-details is sent to programmer for rectification and re-interpretation. 10101100 01101010

This translate-and-execute process continues until the end of the program reached.

When an error is found, interpretation stops immediately, and error-details is reported to the programmer for rectification and re-interpretation.

Differences between Interpreters and Compilers

Interpreter workflow source code (high level lang.) single instruction Interpreter instruction has error? yes no stop running, report error for rectification machine code (machine lang.) execute if instruction has output next instruction


An assembler functions almost like a compiler, where assembly language is the source code. It translates a program written in assembly language into machine language. The symbolic instructions of an assembly language program is converted into executable codes for execution by the CPU. An assembler is the compiler of assembly language.

source code assembly language Assembler object code machine language

In a nutshell, compilers, interpreters and assemblers are basically translators. They all ultimately translate human-readable codes into machine language, but they do it in different ways.

--- x ---

Want to leave a message for me?