Introduction to Compiler Design

In this class, We discuss Introduction to Compiler Design.

For Complete YouTube Video: Click Here

The reader should have prior knowledge of understanding the compiler. Click Here.

To understand the concept, the reader should understand previous classes.

We take an example and understand the concept of the compiler.

Example:

#include <stdio.h>

#define z 8

main ()

{

int x, y;

x= z * y;

}

We should convert the program from a high-level language to machine level language.

Different programs will execute along with the compiler to convert the source code to machine code.

The above program has a header file and a macro.

We need some of the code presented in the header file.

We use the macro to replace z with 8.

The below diagram shows the different programs and their responsibilities during conversion.

We give the source program as input to the pre-processor.

The pre-processor will replace the macro value in the source code.

The output of the pre-processor is the modified source program.

We give the modified source program as input to the compiler.

The compiler will output the target assembly code.

In our following classes, we discuss them in detail compiler.

We give the target assembly code as input to the assembler.

The assembler will output relocatable machine code.

For relocatable machine code understanding, click here.

We give the relocatable code as input to the linker and loader.

Suppose the source program uses a code present in some other file.

The linker software is responsible for getting the address of the other file.

The relocatable code for library files is present in the lib folder.

The loader will take the code brought from the linker, the relocatable source code, and the relocatable library code. And convert to target machine code.