Unit 5 Compiler Interpreter
Unit 5 Compiler Interpreter
Unit 5 Compiler Interpreter
• The job of a piece of software known as a loader is to take the object code generated by compilation and to find a
'good' place for it in RAM, where it can then be executed. Imagine that a software house has written a program to sell
to the public. They wrote the source code, compiled it so that they then had some object code, and then copied the
object code onto a CD, ready to sell. They wouldn't distribute the source code because they would want to keep the
actual program code secret from competitors - it is practically impossible to turn object code back into source code.
Besides, your customers may not have the necessary compilers on their machines to convert the source code into
object code. In addition, it would be a little inconvenient if your customers had to compile every program they
wanted to use before they actually used it!
• If you bought the CD and wanted to run the program, you might double click on the .exe file. The loader would then
copy the object code from the CD into your RAM and run it from there. But where in RAM would the loader put it?
You have other applications running in RAM, for example, the operating system and a virus checker. You may also be
multi-tasking, with various programs and data in RAM. If the loader is not careful, it will load a program in a place in
RAM that interferes with other programs. Your loader program, then, must decide where to put the object code in
RAM so that it doesn't interfere with other programs and data. This is the first main job of the loader program.
• The second main job involves adjusting references that are used within a program. Programs can be written by
programmers using either ‘absolute addressing’ or ‘relative addressing’. Relative addressing is more common
because then the loader can put the program anywhere in RAM - absolute addressing isn't flexible.
Cross Compilers
• Cross Compilers are compilers that execute on one computer and
generate object code that can execute on different platform.
• for example a cross compiler that is running on windows pc can
produce object code that run on MAC Os or Android Os.
Native Compiler Cross Compiler
Translates program for same hardware/platform/machine on Translates program for different hardware/platform/machine
it is running. other than the platform which it is running.
It is used to build programs for same system/machine & OS It is used to build programs for other system/machine like
it is installed. AVR/ARM.
It can generate executable file like .exe It can generate raw code .hex