In
computing system compiler is a program which convert one type language to
another language which is understandable by the computer or
microcontroller. In Computer programming
programs are written in some type of high level language such as C,C++ etc and
computer can understand the machine(in the form of 0’s and 1’s) language.
So
a compiler compile or translate the high level programming language to low
level language which is understand able by computer. In this process it also
take care of spotting the error done by programmers.
Compiler
Main Functions:
The
main function of compiler may be divided in following process. The sequence of
execution of these processes may vary from one compiler to another compiler.
Main functions of compilers are as follows:
Syntax
Error Analysis: In this process compiler will check
the code for if code violates the certain syntax requirement. This will spot
the error in the code and notify to programmer to correct them. For example if
programmer forget to add semicolon “;’ after the code line complier will scan
the code tell the programmer about the line number where semicolon is missing.
Variable
Type Check: In this process compiler will check
syntax error regarding to variable. For
example a variable is used and but not declared, variable initialize with wrong
data type and variable value exceeding in accordance to type defined.
Register
Allocation: Every variable we defined in the
program is in symbolic form. In this process these symbols is converted to some
type of numbers which defines the registers in the specific machine.
Machine
Code Generation: In this process program written in
the C language first converted to assembly language program according to
specific architecture of machine for which program is written. After this
Assembly language code is converted in to machine code language which is the
binary representation of code. This code
is burned in to the program memory of machine.
Difference
between Microcontroller C and Assembly
S.No.
|
Parameter
|
Assembly
Language
|
C Language
|
1
|
System
Dependency
|
Assembly
language is a low level language. Program written in this language will be
machine level language. Every Mnemonic or operand equivalent to some binary
numbers. These operand codes may changes form one architecture to
architecture.
|
C is a middle
high level language. Program written in c language does not required to be
system dependent. If system architecture changes then same program can run on
another system with some or no changes.
|
2
|
Code Size
|
Program written
in assembly language will have small code size.
|
Code size will
be large with C language program.
|
3
|
Faster Execution
|
In assembly
language we get what we have written. All programs written will directly
execution without any translation. Firmware engineer choose assembly language
where faster execution is necessary.
|
Execution of
program written in C language is slower then program written in assembly
language. One line written in C language may represent many lines of assembly
language program.
|
4
|
Development Time
|
Development time
of Assembly language code is large. Programmer should know the system
architecture and all assembly instruction and register information of
machine.
|
Development time
in C language will be small. There are libraries to implement all the
initialization and other processing tasks.
|
5
|
Portability
|
Program written
in assembly language is not portable from one system to another system due to
dependency on system architecture.
|
Program written
in C language are Portable with no changes or with changes of header file.
|
6
|
Optimization
|
There will be no
optimization in program written in Assembly language. Program is directly
burned in to program memory without any changes.
|
There is
optimization of code in compiling process. One line written in c language may
be equivalent to 10 or more line of assembly language. Compiler has the
capability to optimize the code
|
7
|
Easy Of Project
Management
|
When program
become large there will be problem in handling or managing the code.
|
It is easy to
handle the c language program.
|
8
|
Complexity
|
Learning of
Assembly language is hard due to dependent on machine and complexity is more.
|
It is easy to
understand the C language code and complexity is less as compare to assembly
language.
|
No comments:
Post a Comment