Small C
   HOME

TheInfoList



OR:

Small-C is both a subset of the
C programming language ''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
, suitable for resource-limited
microcomputer A microcomputer is a small, relatively inexpensive computer having a central processing unit (CPU) made out of a microprocessor. The computer also includes memory and input/output (I/O) circuitry together mounted on a printed circuit board (PC ...
s and
embedded system An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
s, and an implementation of that subset. Originally valuable as an early
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
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 The Intel 8080 (''"eighty-eighty"'') is the second 8-bit microprocessor designed and manufactured by Intel. It first appeared in April 1974 and is an extended and enhanced variant of the earlier 8008 design, although without binary compatibil ...
by Ron Cain, appeared in the May 1980 issue of '' Dr. Dobb's Journal of Computer Calisthenics & Orthodontia''. James E. Hendrix improved and extended the original compiler, and wrote ''The Small-C Handbook''. Ron bootstrapped Small-C on the
SRI International SRI International (SRI) is an American nonprofit scientific research institute and organization headquartered in Menlo Park, California. The trustees of Stanford University established SRI in 1946 as a center of innovation to support economic d ...
PDP 11/45
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
system with an account provided by John Bass for Small C development. The provided
source code In computing, source code, or simply code, is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the wo ...
was released with management permission into the
public domain The public domain (PD) consists of all the creative work A creative work is a manifestation of creative effort including fine artwork (sculpture, paintings, drawing, sketching, performance art), dance, writing (literature), filmmaking, ...
. Small-C was important for tiny computers in a manner somewhat analogous to the importance of GCC for larger computers. Just like its
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
counterparts, the compiler generates assembler code, which then must be translated to
machine code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very ...
by an available
assembler Assembler may refer to: Arts and media * Nobukazu Takemura, avant-garde electronic musician, stage name Assembler * Assemblers, a fictional race in the ''Star Wars'' universe * Assemblers, an alternative name of the superhero group Champions of ...
. Small-C is a
retargetable compiler In software engineering, retargeting is an attribute of software development tools that have been specifically designed to generate code for more than one computing platform. Compilers A retargetable compiler is a compiler that has been designed ...
. Porting Small-C requires only that the back-end
code generator In computing, Code generation denotes software techniques or systems that generate program code which may then be used independently of the generator system in a runtime environment. Specific articles: * Code generation (compiler), a mechanism to pr ...
and the library to operating system interface calls be rewritten for the target processor.


Language subset

"In May of 1980 Dr. Dobb's Journal ran an article entitled "A Small C Compiler for the 8080s" in which Ron Cain presented a small compiler for a subset of the C language. The most interesting feature of the compiler besides its small size was the language in which it was written—the one it compiled. It was a self-compiler! (Although this is commonplace today, it was a fairly novel idea at the time.) With a simple, one-pass algorithm, his compiler generated assembly language for the 8080 processor. Being small, however, it had its limitations. It recognized only characters, integers, and single dimension arrays of either type. The only loop controlling device was the while statement. There were no Boolean operators, so the bitwise logical operators & (AND) and , (OR) were used instead. But even with these limitations, it was a very capable language and a delight to use, especially compared to assembly language. Recognizing the need for improvements, Ron encouraged me to produce a second version, and in December 1982 it also appeared in Dr. Dobb's Journal. The new compiler augmented Small C with (1) code optimizing, (2) data initializing, (3) conditional compiling, (4) the extern storage class, (5) the for, do/while, switch, and goto statements, (6) combination assignment operators, (7) Boolean operators, (8) the one's complement operator, (9) block local variables, and (10) various other features. Then in 1984 Ernest Payne and I developed and published a CP/M compatible run-time library for the compiler. It consisted of over 80 functions and included most of those in the UNIX C Standard I/O Library—the ones that pertained to the CP/M environment. This became version 2.1 and the subject of The Small C Handbook.


See also

*
BDS C BDS C (or the ''BD Software C Compiler'') is a compiler for a sizeable subset of the C programming language, that ran on and generated code for the Intel 8080 and Zilog Z80 processors. It was the first C compiler for CP/M. It was written by Leor ...
(1979) – C compiler for Z80 and 8080 systems * MISOSYS C (1985) - C compiler for TRS-80 (Z80 CPU) * Tiny C (2002) – C compiler for slow x86 and ARM computers having little disk space


Small-C variants

*
Z88DK Z88DK is a Small-C-derived cross compiler for a long list of Z80 based computers. The name derives from the fact that it was originally developed to target the Cambridge Z88. Z88DK is much developed from Small-C and it accepts many features of ANS ...
– Cross Small-C implementation for Z80 based microcomputers *
cc65 cc65 is a cross development package for 6502 and 65C02 targets, including a macro assembler, a C cross compiler, linker, librarian and several other tools. Overview cc65 is based on a native C compiler that was originally adapted for the At ...
– Cross Small-C implementation for 6502 computers *
Deep Blue C Deep Blue C is a compiler for a subset of the C programming language for the Atari 8-bit family distributed by the Atari Program Exchange (APX). The compiler is a version of Ron Cain's public domain Small-C modified by John Howard Palevich to r ...
– Native Small-C for the
Atari 8-bit family The Atari 8-bit family is a series of 8-bit home computers introduced by Atari, Inc. in 1979 as the Atari 400 and Atari 800. The series was successively upgraded to Atari 1200XL , Atari 600XL, Atari 800XL, Atari 65XE, Atari 130XE, Atari 800XE, ...
* A.J.Travis – Native Small-C for the
BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputers and associated peripherals designed and built by Acorn Computers in the 1980s for the BBC Computer Literacy Project. Designed with an emphas ...


References


Notes

* Ron Cain, "A Small C Compiler for the 8080's", '' Dr. Dobb's Journal'', April–May 1980, pp. 5–19 * James E. Hendrix, ''The Small-C Handbook'', Reston 1984, * James E. Hendrix, ''A Small C Compiler: Language, Usage, Theory, and Design'', M & T Books 1988, * James E. Hendrix, ''Small C Compiler'', M & T Books 1990,


External links


Comments by Ron Cain on creation of Small-CNative compiler for the BBC ComputerDr. Dobb's Small-C Resource CDROM iso-image download
{{Authority control C programming language family 1980 software C (programming language) compilers CP/M software