Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.
Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.
Contents
- 1 Language Processing System
- 2 Stages of the Language Processing System
- 3 1. Pre-Processor
- 4 2. Compiler
- 5 3. Assembler
- 6 4. Linker
- 7 5. Loader
- 8 6. Relocatable Code
- 9 Complete Workflow of Language Processing System
- 10 Summary
- 11 Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.
- 12 compiler design lecture notes
- 13 LOADER AND LINKER – Prof. Anand Gharu
Language Processing System
The Language Processing System is responsible for converting high-level programming code into machine-executable code. It consists of various phases, including Pre-processing, Compilation, Assembly, Linking, and Loading.
Stages of the Language Processing System
Stage | Function |
---|---|
Pre-Processor | Handles macro expansion, header files, and conditional compilation. |
Compiler | Converts high-level code (C, Java, Python) into assembly language. |
Assembler | Translates assembly language into machine code (object code). |
Linker | Combines multiple object files & libraries into a single executable. |
Loader | Loads the executable file into memory for execution. |
Relocatable Code | Code that can be loaded at any memory location instead of a fixed one. |
1. Pre-Processor
Handles macro processing, file inclusion, conditional compilation, and inline expansion.
Works before compilation.
Example in C (Using Preprocessor Directives):
Output after Pre-processing:
- Expands
#define PI 3.14
into actual values. - Includes
stdio.h
functions.
2. Compiler
Translates high-level code → assembly code.
Checks for syntax errors & optimizations.
Example:
Compiler Output: Assembly Code
3. Assembler
Converts assembly language → machine code (binary 0s & 1s).
Generates an object file (.obj
or .o
).
Example Assembly Code:
Assembler Output: 0101 0010 1100 ...
(Binary Machine Code)
4. Linker
Combines multiple object files & libraries into a single executable file.
Resolves external symbols (like printf()
from stdio.h
).
Example:
main.o
+math.o
→ final executable (a.out
or.exe
)
Without a linker, a program won’t run!
5. Loader
Loads the executable file into memory before running it.
Assigns memory addresses to program segments.
Example:
- Loads
.exe
file into RAM when double-clicked.
OS uses loaders to manage program execution.
6. Relocatable Code
Flexible code that can be loaded at any memory address.
Needed in modern operating systems for dynamic memory allocation.
Example:
- Dynamic libraries (
.dll
in Windows,.so
in Linux) use relocation.
Complete Workflow of Language Processing System
Summary
Pre-Processor – Expands macros, includes header files.
Compiler – Translates high-level to assembly language.
Assembler – Converts assembly into machine code.
Linker – Combines object files & libraries.
Loader – Loads the executable file into memory for execution.
Relocatable Code – Allows execution at different memory locations.
Would you like detailed examples or diagrams?