Appendix G:

Changes from Small C 2.1

The most popular MS-DOS version of the Small C compiler to date is version 2.1 as distributed by M&T Publishing. With the publication of this book, however, a new version (2.2) was released. The following material is provided to help you assess the differences and thereby determine how applicable this book may be to the compiler you may already have and whether or not to obtain a copy of the new version.

  1. Several bugs have been fixed.

  2. The optimizer has been entirely rewritten for greater efficiency, maintainability, and understandability. It now does much more optimizing. EXE sizes are down by 10% typically and execution times are down by as much as 25%.

  3. Iscons() was revised to call DOS only the first time for a file and remember the answer thereafter. The effect was a DOUBLING OF I/O SPEED through the get functions.

  4. Strlen() was revised to use the 8086 REPNE SCASB prefix/instruction for the fastest possible operation. This sped up finding a string's length by over 5 times.

  5. The is...() character classification functions have been consolidated into a single module with an array of 128 bytes which are encoded with the various attributes of the ASCII characters. These functions now simply subscript the array and select the appropriate bit. This approach is 3 times faster than before.

  6. Previously-optional compiler features have been made standard. Primarily this includes dynamic allocation of data structures and support for flow-of-control statements that were not in the original Small C compiler.

  7. A general clean up of the source code was performed. This involved consolidating the compiler code into just four files, reorganizing the placement of functions, renaming the p-codes in a systematic way, renaming many functions, purging unused variables, reducing the number of functions, and numerous minor code improvements.

  8. The amount of stack space used by the expression analyzer was reduced by allocating instances of lval2[] (now called is2[]) only when actually needed.

  9. Support for the unsigned integer and character data types was added.

  10. The handling of numeric constants was revised to recognize values from 32768 to 65535 as unsigned, and treat them as such during expression analysis.

  11. Rather than defaulting declarations with multiple modifiers (e.g., *array[]) to something the programmer doesn't intend, they are now rejected.

  12. The compiler now accepts void before function headers as a comment.

  13. The implementation of the sizeof operator was revised to work correctly. Although undocumented, this operator was in the original MS-DOS compiler, but it was incorrectly implemented.

  14. An argument count is now always passed to called functions--even if NOCCARGC is defined. This is not very costly on 8086 family CPUs and it eliminates a lot of headaches when you call printf() but forget that NOCCARGC is defined.

  15. Small C programs now abort with a return code of 1 for memory overflows and 2 for operator interruptions (control-C).

Go to Appendix H Return to Table of Contents