Small-C

Last updated
Small-C
Developers Ron Cain, James E. Hendrix
Initial release1980;45 years ago (1980)
Written in C programming language
Type Compiler
License Copyrighted but sharable

Small-C is both a subset of the C programming language, suitable for resource-limited microcomputers and embedded systems, and an implementation of that subset. Originally valuable as an early compiler for microcomputer systems available during the late 1970s and early 1980s, the implementation has also been useful as an example simple enough for teaching purposes.

Contents

The original compiler, written in Small-C for the Intel 8080 by Ron Cain, appeared in the May 1980 issue of Dr. Dobb's Journal . James E. Hendrix improved and extended the original compiler, and wrote The Small-C Handbook. Ron bootstrapped Small-C on the SRI International PDP 11/45 Unix system with an account provided by John Bass for Small C development. The provided source code was released with management permission into the public domain.[ citation needed ] Small-C was important for tiny computers in a manner somewhat analogous to the importance of GCC for larger computers. Just like its Unix counterparts, the compiler generates assembler code, which then must be translated to machine code by an available assembler.

Small-C is a retargetable compiler. Porting Small-C requires only that the back-end code generator and the library to operating system interface calls be rewritten for the target processor.

Language subset

The original Small-C compiler excluded many features from standard C for minimalism. Types are limited to char and int, while Arrays of these types are restricted to one dimensional arrays only. The only loop statement that is available is the While loop. Boolean operators were not included, meaning that logical statements had to be done with the equivalent bitwise operators, of which only AND and OR were given. Compilation was done in one pass with no optimization, although one could provide the compiler with an optimizer to use.

A second version, now called Version 2.1, of the Small-C compiler was later developed by James E. Hendix, extending Small-C with many features commonly used in C. The new compiler optimized code by default and allowed preprocessor directives for conditional compilation. Added features include boolean operators, For loops, Do while loops, Switch statements, and Gotos. This allowed programming much closer to standard C. [1]

Rick Grehan ported Small-C to MS-DOS and Macintosh in 1988 for a new version of the BYTE benchmarks. [2]

See also

Small-C variants

References

  1. James E. Hendix. "Introduction". A Small-C Compiler: Language, Usage, Theory, and Design. M & T Books 1988 / Dr. Dobb's Journal Developer Network 2005.
  2. Grehan, Rick (July 1988). "The Pitfalls of Porting". Byte . pp. 217–222. Retrieved 2025-04-12.
  3. "C compilers for the BBC Computer". Mdfs.net.

Notes