12.1
A Compiler as a Software Project

12.2
Features, Techniques and Tradeoffs

12.3
Run-Time Storage Management

12.4
Incremental Compiling

12.5
Compiler Example: Borland Turbo Compilers

12.6
Compiler Example: Ada Compilers

12.7
Summary

Web References

Exercises

E-Mail

12.5 Compiler Example: Borland International's Turbo Pascal

The Turbo Pascal compilers are examples of the compilers whose needs are described by the small but fast compiler techniques of Section 12.2.6.

Turbo Pascal supports the full range of standard Pascal as well as a few features of its own such as a byte data type, special array types, additional arithmetic operators, built-in strings and much more.

It is small because it was originally designed for the 86-family of computers with limited physical memory. In fact, it is designed to run in the absence of a hard disk if necessary.

Turbo Pascal is fast, processing more than 30,000 lines/minute on a two MIP (mil- lions of hardware instructions per minute) machine. This translates to 15,000 lines/minute/MIP.

Memory management must deal with the 86-family's segmented architecture (see Lemone, 1986) and with limited operating services. Turbo compilers emphasize environments and come with their own editor and debugger.

Turbo compilers do not follow the textbook structure of separate phases and modular design which would enhance portability, reliability and maintainability, although

they are quite reliable and have been ported to other machines. Such designs would be too large and too slow.

In the original Turbo Pascal, the scanner consumes about 25% of the compiler while the parser takes 30 40% and 30-40% is for code generation. The parser is recursive descent (thus contradicting the belief that recursive descent is not the method of choice for "serious" compilers). The semantic analysis phase is mixed with parsing and does not change to an intermediate representation.

Turbo Pascal has fewer functional interfaces, eliminates many passes and mixes phases.

Earlier versions of Turbo Pascal used a linear symbol table structure. Later versions use a more efficient structure.

Live variable analysis is limited to fewer than 16 variables on 16-bit versions of the 86-family and to 32 bits on the 32-bit versions, so that bit vectors may be used (see Chapter 8). Other optimizations include constant propagation, which is per- formed "on the fly" as the tree is built.

Turbo Pascal does not do error recovery. Because the environment is integrated, the user is put back into the editor when an error is encountered.

Because the original Turbo Pascal is written for the 86-family, whose architecture presents "unique problems", code generation must be aware of special purpose registers. When Turbo Pascal was ported to the 68000, the code generator was reduced by half.

To complete the non-textbook approach: the original Turbo Pascal was written entirely in assembler!