Tuesday 17 July 2012

HOW A SOURCE CODE TRANSLATED TO EXECUTABLE CODE ?


HOW A SOURCE CODE TRANSLATED TO EXECUTABLE CODE ?
We provide Source Code to the complier and it gives us Executable code .But this is not a single step operation .This follow some predefined steps to convert the Source Code to Executable Code.


1.Preprocessor
It is very useful part of the complier as it does lots of job before translated to machine code. It is a text processor which dose the below text editing operation
  • It removes the comment lines in source code which are written in the Source code for more readability/easy understanding .
  • It add the content of header files to the source code. Header files always contains function prototypes and declarations.(Header files never contain any executable code )
  • A very important property of Preprocessor is Conditional Compile. It is very required for scalable design. This property also remove the unnecessary burden from complier.
  • Macros are replaced by this preprocessor.
The final output of this stage is known as pure C code.
2.Translator
This part of complier is responsible for converting of pure C code to assembly language code.
Step by step mapping of C language code to assembly language code done here.
The prototypes of the functions and declarations are used by this part for translation of C code.
The out put of this stage known as assembly code.
3.Assembler
It generate Object code from assembly language code.It converts the assembly language codes to machine language code(i.e in 0's and 1's format).It is not directly run as we take the help of OS to execute our code in processor.
The out put of this stage known as object code.

4.Linker
It give the final executable code which is going to be run in our machine. The output of this stage is known as executable code. Which is a combination of object code and supporting files.
The supporting fies may be function definitions ,predefined library function definitions ...etc.   

No comments:

Post a Comment