Last modified on 22 December 2011, at 19:14

Small C

Revision as of 19:14, 22 December 2011 by TFM (Talk | contribs) (Specific)

In general

"In computing, 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.

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 (with management permission, provided the compiler sources were released as public domain). 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 be rewritten for the target processor.

As of 2007, Small-C—now almost twenty-five years old—is still being used, ported, hacked and studied by people who want to learn how a compiler is written."

(From Wikipedia, the free encyclopedia / Link: http://en.wikipedia.org/wiki/Small-C)

Small C implements int and char, no float, no double, no structure (handled as arrays of contiguous objects instead), no union, no long, no short, no unsigned (int's & char's are signed per K&R), no auto (as keyword; autos are implemented as stack objects), no external (as keyword; provisionally asm globals), no register, no typedef, no static (as keyword; static's are data grouped at the end of code), no goto, return yes, no sizeof, break yes, continue yes, if yes, else yes, no for(;;), no do, while yes, no switch (substituted as list of 'if's'), no case, no default, no entry, .. #include yes, #define yes, #asm..#endasm yes (a near imperative extention). No prototypes, not ansi-c syntaxed, K&R syntax yes.

main (argc, argv) ; This syntax is accepted by small-c but its implementation is so system dependant that Cain wisely chose to ask the operator for parameter inputs thru 'console input' rather than command line parameters to sidestep this implementation detail until a later time.

(From "The -fbin Project / Small-C / Link: http://www.project-fbin.hostoi.com/Proj_SmC/CainC/AboutSmC.txt.html)

Specific

Compiler versions or interpreter for 8080/Z80 in general (look at):

Cross-Compiler

Z88DK

SDCC