Difference Between Compilers and Assembler
Difference Between Compilers and Assembler
Department of CS/IT HU
Instructor: Mir Muhammad Wasiq
Difference between Compiler and Assembler
Both compilers and assemblers are the language processors used to convert software codes
written in high-level language and assembly language into machine language codes.
Why they required
Compiler and assemblers are the types of system software. These are required because a
computer cannot process a code written in high-level programming language like C, C++, Java,
etc. and assembly language. Therefore, it is necessary to convert a HLL or assembly code into
machine code for execution.
In this topic, we will highlight all the key differences between compilers and assemblers. Let's
start with some basics of compiler and assembler so that it will become easier to understand their
differences.
What is a Compiler?
Compiler is used to translate a high level programming language code to machine level
code and to create an executable program. Compiler checks the error in the program and
reports them. All errors are to be removed otherwise code will not be compiled and
executed.
A compiler takes the sources code as the input and translates it into a machine level language
code which is called object code. If there is any syntax or grammatical error in the source code,
the compiler records all these errors. A compiler can only convert a source code written in a
specific high level language. Each HLL language requires a separate compiler for translation.
Some common examples of compilers are – for Java (JDeveloper, BlueJ, etc.), for
C++ (Code Block, GCC, etc.), for Python (JPython, Spyder, etc.).
What is an Assembler?
An assembler is used to translate an assembly level code to machine readable code.
Assemblers too check the correctness of each instruction and report the diagnosis report.
In assembly language, the program is written using mnemonics (i.e. abbreviated names assigned
to binary codes). The assembler converts these mnemonics into binary code so that CPU of the
computer can understand and execute them to perform a task. Therefore, the input program to an
assembler is a source code containing mnemonics, while the output is a program containing
machine language codes.
Some common examples of assemblers are GAS, MASM, NASM, etc.
Conclusion
The most significant difference between a compiler and an assembler is that a compiler
converts a high-level language program into a machine level language program, whereas
an assembler converts an assembly language program into a machine language program.