Compilation is the process of converting human-readable code (High-Level Language) into machine-readable code (Binary). This happens in four distinct stages:
Preprocessing: The preprocessor handles directives starting with # (like #include). It expands macros and includes the contents of header files into the source code.
Compilation: The expanded code is translated into Assembly Level Language, which is a low-level instruction set specific to the computer's processor.
Assembly: An assembler converts the assembly code into Object Code (machine code), usually resulting in a .obj or .o file.
Linking: The linker combines your object code with library files (like stdio.h functions) to create a single Executable File (e.g., .exe on Windows or .out on Linux).
Once the executable file is created, the execution phase begins:
Loading: When you run the program, the Operating System's Loader brings the executable file from the hard drive into the RAM (Random Access Memory).
Entry Point: The CPU starts executing instructions beginning at the main() function.
Instruction Cycle: The CPU follows the "Fetch-Decode-Execute" cycle for every line of code until the program hits a return statement or the end of main().
| Stage | Input | Output | Purpose |
| Preprocessing | .c file | .i file | Handles # directives and macros. |
| Compilation | .i file | .s file | Converts C to Assembly code. |
| Assembly | .s file | .o / .obj | Converts Assembly to Machine code. |
| Linking | .o files | .exe / .out | Merges code with libraries. |
| Execution | Executable |
Copyright ©2025. All Rights Reserved Emblab THE RAVE INNOVATION