C.2.8
THEORY OF OPERATION The creation of an executable file from a C source file can be considered to occur in four distinct phases: a compilation phase, followed by an assembly phase, followed by a linking phase, followed by a loading phase. Under Introl-C, however, the assembly phase is always initiated automatically when the compilation phase terminates, and the loading phase is initiated automatically when the linking phase terminates. Thus, it will normally appear to the Introl-C user as though only two phases are actually involved: a compilation/assembly phase (which is initiated via a single compiler command line call), and a linking/loading phase (which is initiated via a single linker command line call). COMPILATION PHASE The compilation phase, per se, is performed by the Compiler and translates a C source text file into an assembly language text file which is suitable for input to the Assembler. The Compiler converts a C source file into assembly language by seqentially executing four separate compilation programs, or "passes", which are called passes "cO", "c1", "c2", and "c3", respectively. (Note: The "cO" pass is alternatively called the "icc" pass for some operating system versions of Introl-C.) Each of these passes performs a unique function in the overall compilation process and, as each pass finishes, it automatically initiates the next pass in the sequence. The basic function of the c0 pass, also known as the "preprocessor", is to preprocess the C input text, removing comments and other white space from the C-source text and executing any preprocessor directives, ultimately transforming the original C input into a series of tokens that can be more easily manipulated and analyzed. If illegal characters appear in the C source text, or preprocessor directives have been used improperly, the c0 pass will detect these and flag them as errors. The cl pass, also called the "parser", converts the output of the cO pass into two resultant files: a triple file, which is a tree representaion of the original program, and a symbol file. The cl pass also checks the program for semantical and grammatical accuracy and is responsible for detecting and reporting any errors of this type. The function of the c2 pass, also called the "optimizer", is to optimize the triple file generated by cl to reduce the size and increase the execution speed of the final program. The c3 pass, called the "code generator", uses the optimized triple file produced by c2, together with the symbol table produced by cl, to produce an assembly language output file for the target processor. The several Compiler passes transfer information between one another via temporary files, which are normally automatically deleted once their contents are no longer needed by the Compiler. The final result of the 4-pass compilation phase, therefore, is the creation of an assembly language text file which is suitable input C.3.1