Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Computers are a well-balanced combination of software and hardware. Hardware is simply a mechanical device whose operations are determined by the software that controls it. The hardware interprets instructions as an electrical charge, similar to the binary language used in software programming. There are just two alphabets in binary: 0 and 1. The hardware codes must be encoded in binary format, which is just a series of 1s and 0s, in order to instruct.
For computer programmers, writing such code would be inconvenient and complex, so we design programs in a high-level language (e.g., C, C++, Python, Java, etc.) that is easy to understand and learn. These programs are then passed into a sequence of devices and operating system (OS) components to generate the desired machine code known as a language processing system.
Let’s learn about the language processing system in-depth.
The programs that are written in high-level languages (e.g., C, C++, Python, Java, etc.) are passed into a sequence of devices and operating system (OS) components to generate the desired machine code that can be understandable by machine, known as a Language Processing System.
The different components of the Language processing system are given in the below diagram.
Let’s understand the different components of the Language processing system one by one:-
Preprocessor
A source program can be broken down into modules, each of which is saved in its own file. A pre-processor is responsible for gathering the source program. All header files are included in the preprocessor, which also checks for a macro's presence. It accepts source code and outputs updated source code.
Macro: A macro is a chunk of code that has a name assigned to it. An interpreter or compiler replaces the name with the contents of the macro whenever it is used. Macros are used to automate the frequency with which sequences are run or to provide more powerful abstraction.
Example: #include<iostream> here # is a pre-processor directive. It copies all library functions of iostream (standard input-output) file into a program.
Compiler
A compiler is computer software that transforms source code written in one computer language (the source language) into another computer language (the target language).
The compiler is used for programs that translate source code from a high-level programming language (e.g., C++, Python, Java, etc.) to a lower-level language (e.g., assembly language or machine code).
Assembler
An assembler converts the assembly language code into machine code. The output of an assembler is known as an object file, which comprises a combination of machine instructions and the data needed to store them in memory.
Linker
A linker is a computer program that combines and links many object files to create one executable file. All of these files could have been created by different assemblers. A linker's primary function is to search and find referred modules in a program and establish the memory address where these codes will be loaded, resulting in absolute references in program instructions.
Loader
The loader is an operating system component that loads and executes executable files into the main memory. It calculates a program's size (instructions and data) and allocates RAM. It starts execution by initializing specific registers.
Executable Code
It's a low-level, machine-specific code that the machine can interpret. After the linker and loader have completed their tasks, the object code is eventually transformed into executable code.
A compiler is computer software that transforms source code written in one computer language (the source language) into another computer language (the target language).
What is a Cross-Compiler?
A compiler that runs on the platform (X) and can generate executable code for the platform (Y) is known as a cross-compiler.
What is an Interpreter?
An interpreter, like a compiler, converts high-level programming languages into machine code. An interpreter takes a statement from the input, translates it to intermediate code, executes it, and then moves on to the following statement. The interpreter will halt the process and report it if an error occurs.
Conclusion
In this article, we have extensively discussed the Language Processing System in Compiler Design, various components of the Language Processing System, and the functioning of these components.