Small-C

Revision as of 04:29, 13 April 2025 by imported>Ylee (→‎Language subset: Cite fix)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description Template:Distinguish {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other 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. The provided source code was released with management permission into the public domain.Template: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 subsetEdit

Template:Over-quotation

"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 ones' 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."<ref>Template:Cite book</ref>

Rick Grehan ported Small-C to MS-DOS and Macintosh in 1988 for a new version of the BYTE benchmarks.<ref name="grehan198807">Template:Cite magazine</ref>

See alsoEdit

  • BDS C (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 variantsEdit

  • Z88DK – Cross Small-C implementation for Z80 based microcomputers
  • cc65 – Cross Small-C implementation for 6502 computers
  • Deep Blue C – Small-C for the Atari 8-bit computers
  • A.J.Travis – Native Small-C for the BBC Micro<ref>{{#invoke:citation/CS1|citation

|CitationClass=web }}</ref>

ReferencesEdit

Template:Reflist

NotesEdit

  • 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, Template:ISBN
  • James E. Hendrix, A Small C Compiler: Language, Usage, Theory, and Design, M & T Books 1988, Template:ISBN
  • James E. Hendrix, Small C Compiler, M & T Books 1990, Template:ISBN

External linksEdit

Template:Authority control