This preview shows page 1. Sign up to view the full content.
Unformatted text preview: necessary that each computer
must have its own "personal" compiler for a particular language, say LI. Figure
12.9 illustrates how machine-independence is achieved by using different
compilers to translate the same high-level language program to machine language
programs of different computers.
Compilers are large programs, which reside permanently on secondary storage.
When a source program is to be translated, the compiler and the source program
are copied from secondary storage into the main memory of the computer. The
compiler, being a program, is then executed with the source program as its input
data. It generates the equivalent object program as its output, which is normally
saved in a file on secondary storage. Whenever there is a need to execute the
program, the object program is copied from secondary storage into the main
memory of the computer and executed. Note that there is no need to repeat the
compilation process every time you wish to execute the program. This is because
the object program stored on secondary storage is already in machine language.
You simply have to load the object program from the secondary storage into the
main memory of the computer, and execute it directly. Also note that compilation
is necessary whenever we need to modify the program. That is, to incorporate
changes in the program, you must load the original source program from
secondary storage into the main memory of the computer, carry out necessary
changes in the source program, recompile the modified source program, and create
and store an updated object program for execution.
In addition to translating high-level language instructions into machine language
instructions, compilers also automatically detect and indicate certain types of
errors in source programs. These errors are referred to as syntax errors and are
typically of the following types:
1. Illegal characters
2. Illegal combination of characters 3. Improper sequencing of instructions in a program
4. Use of undefined variable names
A source program containi...
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14