sponsored links
As you know, writing a compiler for any high level language is a complicated process. It takes lots of time to write a compiler from scratch. Hence simple language is used to generate target code in some stages.
Confused ? to clearly understand the bootstrapping technique consider the following scenario.
Suppose we want to write a cross compiler for a new language say X. The implementation language of this compiler is say Y and the target code being generated is in language say Z. That is, we create
XYZ. Now if existing compiler Y (i.e., compiler written in language Y) runs on machine and generates code for M then it is denoted as YMM. Now if we run XYZ using YMM then we get a compiler XMZ. That means a compiler for source language X that generates a target code in language Z and which runs on machine M.
Following diagram illustrates the above scenario.
Now lets have a look at an example to understand the concept in more detail,
Example : We can create compilers of many different forms. Now we will generate compiler which takes C language and generates an assembly language as an output with the availability of a machine of assembly language.
Step 1 : First we write a compiler for a small subset of C in assembly language.
Step 2 : Then using this small subset of C i.e., C0, for the source language C the compiler is written.
![]() |
Compiler 2 |
Step 3 : Finally we compile the second compiler. Using the compiler 1 the compiler 2 is compiled.
Step 4 : Thus we get a compiler written in ASM which compiles C and generates code in ASM.
That's all for now friends. In our next post we shall discuss about the Interpreter. Happy Reading :)
sponsored links
Thank you Ma'am.... In step 3, what is the target???
ReplyDelete** What is the target of compiler 2??
DeleteASM
ReplyDelete