<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 22 Apr 1986 14:30:40 GMT
From   : clewis%mnetor.uucp@BRL.ARPA
Subject: Re: req. C compiler

In article <85@brl-smoke.ARPA> Ghenis.pasa@xerox.ARPA writes:
>Small-C is cute, but non-standard. For as little as $39.95 you can get
>MIX-C, which claims to be full K&R standard compatible, and comes with a
>400 page manual and tutorial (a very good value, in my opinion). The
>tradeoff is it doesn't produce very efficient code. There are other C
>compilers for CP/M for under $100, see magazines like Byte, Dr. Dobbs,
>etc for ads. If you're interested in learning about compilers, Q/C comes
>with full source for itself written in C ($99 for the whole package).

I think you're confusing "Small-C" with "Tiny-C".  Tiny-C isn't really C,
its syntax is rather different.  If I recall correctly, Tiny-C was an
interpretive language, and about the first thing even close to C on the
market for micros.  I think that it came without machine-readable media,
and you had to type in the interpreter code (but I may be completely out
of wack).  I think that it was the first package Lifeboat ever distributed.

Small-C V1.0 was written by Ron Cain, complete sources including bare-bones
8080 run-time support were published in Dr. Dobbs about 4-5 years ago.  
It's syntax was *almost* completely compatible with C (only a minor bitch 
or two - which we fixed), and it is a subset: was missing a couple
of statement types, only allowed the following declarations:
       char ...
       char *...
       char ...[]
       int ...
       int *
       int ...[]
(No structs, unions, initializers, longs, unsigneds, floats, doubles, or more
than one "indirection"), and a few other minor glitches (eg: missing all
of the assignment operators except "=" etc.).

It was a fairly impressive achievment even so - Ron Cain had obviously
never seen a compiler before (eg: it had no true "scanner" - which would have
speeded it up rather drastically), and, inspite of the drastic subsetting,
could compile itself rather handily - on a single SSSD 8" CPM disk!

Small-C didn't optimize the output (assembler by the way) at all.  Even so,
we were rather startled to see its generated code outperforming interpretive 
BASICs by two orders of magnitude, and some commercially available (and
expensive) Pascals by a factor of 5 (this was on a 6809).  I included Small-C
into my M.Sc. thesis (on the implementation of Concurrent Euclid, and compiler
benchmarks) just for laughs - the benchmarks weren't all that bad.
A friend of mine wrote an awk-based assembler optimizer that got size gains
of %40 (and higher speed gains), still without even folding constant 
expressions.

This same friend of mine and I typed the sources in, and over a year or so, got
it ported and self-compiling on 8080's, 6809's, pdp11's, vaxes and a
few other machines I can't remember.  It was neat - only took about 8 hours
of work to port to a new machine once you understood how the code generator
worked.  My friend, inspired by playing around with the guts, went on
to reimplement it completely using proper compiler techniques and "heavy"
optimization.  [PT?  Are you listening?  Or, have you forgotten CPM 
altogether?  How about uploading SCC V3 one of these days - if you can
find it...)

Since then I've extended a version (8080, 6809, pdp11 and vax targets) so
as to add all of the statements that were missing, plus ensure that all
operators were implemented plus a lot of other things.  I've often
thought about adding structs and initializers etc., but I'm afraid that
without optimization the durn thing won't fit in 56k.  Further, I've
"disconnected" the compiler's front end from machine-dependencies - I
have an archive containing the compiler's front end binaries, you merely 
have to link in a different code generator (about 9K of source) to retarget
the compiler to a different machine.  We used to do cross-compile the
compiler, download the resultant assembler to the target, assemble and link, 
and voila!

It's a great compiler to cut your teeth on - accompanied by a compiler
construction book it makes a great learning experience.

About 1 1/2 years later, someone else published in Dr. Dobbs a new version 
of Small-C (called Small-C V2.0) that had been greatly extended.  However, 
V2.0 version is a subset of what I have now.

During this time Dr. Dobbs published several C programs intended for
use with this compiler, including a full-screen editor.

Since this time, however, with the availability of full-blown C compilers
really cheap, most people have been drifting away from Small-C.

Regarding Q/C and MIX-C: unless my memory is completely faulty, *both*
of these compilers *are* (or were) Small-C, but greatly extended.  I'm 
absolutely certain Q/C is (which is why it's so cheap and why source 
is released).  Both of them have been extended at least as far as 
structs/unions, but not floating point (I think).  I would imagine that
they don't optimize much either.

If there's sufficient interest, I'll post the sources to the whole
shebang on mod.sources.  It may not be the best compiler (I'd recommend
something better for serious work - even so, I know of at least one company
that really uses it in their products), but it's fun to play with.  And,
if you *need* a "compiler" on a new machine, it's the fastest way to go.
-- 
Chris Lewis,
UUCP: {allegra, linus, ihnp4}!utzoo!mnetor!clewis
BELL: (416)-475-8980 ext. 321
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>