Open In App

Language Processing System in Compiler Design

Last Updated : 31 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The computer is an intelligent combination of software and hardware. Hardware is simply a piece of mechanical equipment and its functions are being compiled by the relevant software. The hardware considers instructions as electronic charge, which is equivalent to the binary language in software programming. The binary language has only 0s and 1s. To enlighten, the hardware code has to be written in binary format, which is just a series of 0s and 1s. Writing such code would be an inconvenient and complicated task for computer programmers, so we write programs in a high-level language, which is Convenient for us to comprehend and memorize. These programs are then fed into a series of devices and operating system (OS) components to obtain the desired code that can be used by the machine. This is known as a language processing system.

Language Processing System

Components of Language processing system:

You have seen in the above diagram there are the following components. Let’s discuss it one by one.

Preprocessor: It includes all header files and also evaluates whether a macro(A macro is a piece of code that is given a name. Whenever the name is used, it is replaced by the contents of the macro by an interpreter or compiler. The purpose of macros is either to automate the frequency used for sequences or to enable more powerful abstraction) is included. It takes source code as input and produces modified source code as output. The preprocessor is also known as a macro evaluator, the processing is optional that is if any language that does not support #include macros processing is not required.

Compiler: The compiler takes the modified code as input and produces the target code as output.

Input-Output

Assembler: The assembler takes the target code as input and produces real locatable machine code as output.

Linker: Linker or link editor is a program that takes a collection of objects (created by assemblers and compilers) and combines them into an executable program.

Loader: The loader keeps the linked program in the main memory.

Executable code: It is low-level and machine-specific code that the machine can easily understand. Once the job of the linker and loader is done the object code is finally converted it into executable code. 

Differences between Linker/Loader: The differences between linker and loader are as follows.

Functions of loader:

  1. Allocation: It is used to allocate space for memory in an object program. A translator cannot allocate space because there may be overlap or large waste of memory.
  2. Linking: It combines two or more different object programs and resolves the symbolic context between object decks. It also provides the necessary information to allow reference between them. Linking is of two types as follows.
    Static Linking: It copies all the library routines used in the program into an executable image. This requires more disk space and memory.
    Dynamic Linking: It resolves undefined symbols while a program is running. This means that executable code still has undefined symbols and a list of objects or libraries that will provide definitions for the same.
  3. Reallocation: This object modifies the program so that it can be loaded to an address different from the originally specified location, and to accommodate all addresses between dependent locations.
  4. Loading: Physically, it keeps machine instructions and data in memory for execution.
Linker Loader
The linker is part of the library files. The loader is part of an operating system.
The linker performs the linking operation. The loader loads the program for execution.
It also connects user-defined functions to user-defined libraries. Loading a program involves reading the contents of an executable file in memory.
Linker Combines object files into a single executable file. Loader Loads executable files into memory for execution.
Object files generated by the compiler. Executable files generated by the linker.
Linker is a Single executable file. Loader loads the program into memory.
Linker assigns memory addresses to code and data sections. Loader Allocates memory for the program in the process space.
Resolves external references between object files. Resolves external references between executable files.
Linker does not execute the program. Loader executes the program in memory.
Linker occurs during compilation. Loader occurs during program execution.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads