[net.micro.cpm] req. C compiler

kenb@techsup (04/09/86)

can anyone recommend a decent C compiler?  i'd prefer something in the
public domain.  last night i came across a Dr. Dobbs book titled 
"Small-C" which contains source for a compiler.  does anyone have any
comments on this book or the compiler in it?

I'll appreciate any help anyone can give.

thanks,
ken

uucp:	!ihnp4!sys1!techsup!kenb

Ghenis.pasa@xerox.ARPA (04/17/86)

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).

tom@MITRE-BEDFORD.ARPA (04/17/86)

illuminate me.... what is Q/C?  It sounds interesting as I'm interested in
compilers.

Trevor O. McCarthy
The MITRE Corporation

Ghenis.pasa@xerox.ARPA (04/17/86)

I don't know much about Q/C, just remember that it got a good review
some time ago when Dr. Dobbs (or was it Byte, or Computer Language
magazine, or all three?) featured a review of several C compilers for
CP/M. The fact that it included its own source code in C made it an
especially good value from an educational standpoint.

PS: Our mailer refused to cc: to techsup.arpa. Kenb@techsup.arpa, could
you please send me <ghenis.pasa@xerox.com> a private message confirming
the existence of this host so I can ask for a mailer update?

clewis@mnetor.UUCP (Chris Lewis) (04/22/86)

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

jnp@calmasd.CALMA.UUCP (John Pantone) (04/23/86)

In article <3362@mnetor.UUCP>, clewis@mnetor.UUCP (Chris Lewis) writes:
> 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.  
	
Dr. Dobbs' now offers the "latest and greatest" Small-C source on disk
for around $30. And the documentation in book form for even less.

> It's syntax was *almost* completely compatible with C (only a minor bitch 
> than one "indirection"), and a few other minor glitches (eg: missing all
> of the assignment operators except "=" etc.).

New version has all assignment operators, and multiple indirection.

> 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.  
 
Does so now - with a pee-hole optimizer compile-time option.

[ a bunch of stuff deleted ...]
 
> 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.

Q/C has an optional MATHPAK which extends the spec to include floating point.
It does handle structures, but not unions (I think), and definately not bit
fields.

MIX is a full blown - K&R C, structs, unions, floating point - the whole
shebang.  It is not a fast compiler, nor does it produce very tight code,
but it is far and away the cheapest full C compiler on the market.

[more editing...]

=====================================================================
=     These opinions are mine, all mine and nothing but mine.       =
=       They in no way reflect the opinions of my employer.         =
=                                                                   =
=   John Pantone  	 ...{ucbvax | decvax}!sdcsvax!calmasd!jnp   =
=     GE/Calma  	          jnp@calmasd.UUCP                  =
=  9805 Scranton Rd.  	           (619) 587-3125                   =
= San Diego CA 92121                                                =
=====================================================================