Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Difference Between Compilers and Assembler

Uploaded by

jk716773
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Difference Between Compilers and Assembler

Uploaded by

jk716773
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Organization and Assembly language

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.

Difference between Compiler and Assembler


The following table highlights all the important difference between a Compiler and an
Assembler −
Factor Compiler Assembler
Assemblers convert the assembly
Compilers translate high level programming
Operation level language to machine level
language code to machine level code
code.
Source code in high level programming
Input Assembly level code as input.
language.
Assemblers generally do not
Conversion Compilers check and convert the complete code
convert complete code at one
type at one time.
time.
Lexical analyzer, Syntax analyzer, Semantic
Components analyzer, Code optimizer, Code generator, and Assemblers work in two passes.
Error handler
Output Mnemonic version of machine code. Binary version of machine code.
Examples C, C++ , Java compilers. GAS, GNU assemblers.

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.

You might also like