Reference Book:
Compilers: Principles, Techniques and Tools
Any high level language contains some include statements that refer to external files such as #include, import etc. The preprocessor removes these lines (and also some macros, such as using #define) by substituting these files into the source program. This modified program serves as input to the compiler.
Note: There are source-to-source compilers which translate from one high level language to another. Mostly, the target language is C, as it is highly optimized and efficient for conversion to assembly program.
The compiler then translates it into assembly program. The advantage of producing assembly language rather than machine language directly is that assembly language is easier to produce and also easier to debug. Assembly language is an intermediate between the high level language and machine language. Therefore, it is logical to use an assembler instead of directly compiling to machine code, as it eases the load off the programmers.
The assembler then converts the compiled code into relocatable machine code. Finally, the linker links all the files referred by the program such as libraries etc. and the loader puts all the executable object files together and loads the program into memory.
Saturday 20 February 2016