- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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. 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 an HLL or assembly code into machine code for execution.
In this article, 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 |
---|---|---|
Operation | Compilers translate high level programming language code to machine level code | Assemblers convert the assembly level language to machine level code. |
Input | Source code in high level programming language. | Assembly level code as input. |
Conversion type | Compilers check and convert the complete code at one time. | Assemblers generally do not convert complete code at one time. |
Components | Lexical analyzer, Syntax analyzer, Semantic analyzer, Code optimizer, Code generator, and Error handler | Assemblers work in two passes. |
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.
- Related Articles
- Difference Between Compiler and Interpreter
- What is the difference between One-Pass Compiler and Multi-Pass Compiler?
- What is the difference between Compiler and Interpreter?
- What is the difference between Definitions and Declarations in Compiler design?
- What is the difference between DFA and NFA in compiler design?
- What is the difference between SLR, CLR, and LALR Parser in compiler design?
- What is the difference between Procedural and Non-Procedural Languages in compiler design?
- What is the difference between Imperative languages and Functional languages in compiler design?
- Generation of .OBJ file using a cross-assembler
- Difference Between & and &&
- How is JIT compiler different from normal compiler?
- Difference between Voltage Drop and Potential Difference
- How do you get assembler output from C/C++ source in gcc?
- Why Does Java Use both Compiler and Interpreter?
- Difference between JCoClient and JCoDestination
