Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.

Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.

 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):

#include <stdio.h> // File Inclusion
#define PI 3.14 // Macro Expansion

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:

int main() {
printf("Hello, World!");
return 0;
}

Compiler Output: Assembly Code

 3. Assembler

 Converts assembly language → machine code (binary 0s & 1s).
 Generates an object file (.obj or .o).

Example Assembly Code:

MOV AX, 05h
ADD AX, 03h

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.ofinal 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

[Source Code][Pre-Processor][Compiler][Assembler][Linker][Loader][Execution]

 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?

Language processing system – Pre-processor/Compiler Assembler /Linker/ Loader/Relocatable.

compiler design lecture notes

Leave a Reply

Your email address will not be published. Required fields are marked *

error: