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

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

play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

 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

In computer science, especially in language processing systems (used in compiling and executing programs), several components work together to translate high-level code (like C, C++, etc.) into machine-executable format. Here’s a breakdown of the complete Language Processing System:


📘 Language Processing System Components

1. Pre-processor

  • 📌 Function: Performs text substitution, macro expansion, and removes comments.
  • 🧠 Example: Converts #include and #define directives in C/C++.
  • 🔧 Output: Modified source code (still in high-level language).

2. Compiler

  • 📌 Function: Translates high-level language code into assembly language or machine-level object code.
  • 🔍 It checks for:
    • Syntax errors
    • Semantic errors
    • Optimizes the code
  • 🔧 Output: Object file (.obj or .o)
    Example: main.c → main.o

3. Assembler

  • 📌 Function: Converts assembly code into machine code (object code).
  • 🔧 Input: Assembly language file (.asm)
  • 🔧 Output: Object code in binary (.obj or .o)

4. Linker

  • 📌 Function: Combines multiple object files and libraries into a single executable file.
  • 🧠 Also resolves:
    • Function calls between different files
    • External libraries (e.g., math.h)
  • 🔧 Output: Executable file (.exe, .out)

5. Loader

  • 📌 Function: Loads the executable file into main memory (RAM) for execution.
  • 🧠 Assigns memory space and sets the program counter (PC) to the starting point of the program.

6. Relocatable Code

  • 📌 Definition: Code that can be loaded at any memory location and still run correctly.
  • 🧠 Usually produced by compilers/assemblers to allow modular programming and memory management flexibility.

🔁 Summary of Flow:

Source Code (C/C++ etc.)
     ↓
[Pre-Processor]
     ↓
Modified Source Code
     ↓
[Compiler]
     ↓
Assembly/Object Code
     ↓
[Assembler]
     ↓
Object Code (.obj/.o)
     ↓
[Linker]
     ↓
Executable File (.exe)
     ↓
[Loader]
     ↓
Execution in RAM

If you’d like a diagram, PDF note, or explanation in Hindi, let me know!

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

UNIT -1 a. Compiler b. Interpreter c. Preprocessor …



Leave a Reply

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

error: