[net.lang.c] Small C?

gvg@hp-pcd.UUCP (gvg) (03/31/85)

from: G.V.  Goebel / Hewlett-Packard, Corvallis OR
date: Sunday, March 31 1985

I have heard rumors about a "free" "C" compiler called "small C", written
by a fellow named Ron Cain.  

Does anybody know much about this?  Does it run on UNIX systems?  Where 
would I find it?

                                       Regards - GVG
                                       hplabs!hp-pcd!gvg

rpw3@redwood.UUCP (Rob Warnock) (04/03/85)

+---------------
| from: G.V.  Goebel / Hewlett-Packard, Corvallis OR
| I have heard rumors about a "free" "C" compiler called "small C", written
| by a fellow named Ron Cain.  
| Does anybody know much about this?  Does it run on UNIX systems?  Where 
| would I find it?
+---------------

See the book "The Small-C Handbook", by James E. Hendrix,
Reston Publishing (1984), ISBN 0-8359-7012-4, paperback (256pp).

From the Introduction:

	     "In May of 1980, Dr. Dobb's Journal ran an article entitled,
	<<A Small C Compiler for the 8080's>>. In the article, Ron Cain
	presented a small compiler for a subset of the C language. The
	most interesting feature, besides its small size, was [it was
	written in Small-C]...
	     "Ron Cain published a complete listing of the compiler and
	graciously placed it in the public domain. Both the compiler
	and the language came to be known as Small-C...
	     "Recognizing the need for improvements, Ron encouraged me
	to produce a second version, and in December of 1982 it appeared
	in Dr. Dobbs Journal... [list of various improvements]... This book
	describes an updated version (2.1) of that compiler and its language."

On the copyright page (or whatever that page is properly called), there is
an address for Hendrix that you can send $25 to get the sources and binaries
for Small-C, on "standard 8-inch SSSD CP/M diskettes". It uses Microsoft's
MACRO-80 assembler. (Or I suppose you could type it in from the book, since
it's all there, but it's 78 pages of ~50 lines each, including the runtimes.)

NOTA BENE: Although the language accepted by Small-C 2.1 has been upgraded
to be much closer to "full" C (specifically in terms of control structures,
various operators, and preprocessing -- "#include", "#define", #ifdef", etc.),
Small-C is VERY 8080-specific! It generates 8080 assembler (including the
"#asm" construct), and the runtime library routines (for 16-bit arithmetic,
multiply, etc.) are written in 8080 assembler.

Remember, Small-C is still a "small" C:

	- The only data types are "char" and "int" (no long/short/unsigned)
	- Arrays may have only one dimension
	- No "struct" or "union" (!)
	- No casts (non needed)

On the plus side, most of the minor source syntax irritations found
in the first version have been fixed (other than the really major ones
listed above).  An appendix, "Compatibility with Full C", is only 2.5
pages, mostly small nits.  While some of them impair compatibilty with
certain questionable constructs in "normal" C (e.g., Small-C does NOT
accept "8" and "9" in octal constants), I saw nothing major if you are
writing in "clean" C. With a small amount of attention to the items
mentioned there, you can write Small-C code that is completely portable
to full C compilers.

All in all, a nice small ad-hoc compiler (as opposed to one using "yacc"
or other compiler generators) for a very restricted environment. Worth
studying if you need a TINY compiler for some other (equally restricted)
environment.  I see no problem with your compiling it and running it
*on* a Unix system (say, in doing cross-development), since the Small-C
compiler itself should be compilable by most Unix C compilers.

However, it certainly cannot handle the constructs commonly used in
*writing* a Unix-like system. For example, it would not be able to
compile Doug Comer's "Xinu" code (which makes heavy use of structs).
The lack of structs and unions is a serious limitation, given modern
systems programming style.

Should you need a compiler for a machine that does not normally have
one, and you are going to be running the compiler on a Unix system
that has "yacc", you might want to look at the "yacc" grammar for
ANSI C that was posted to the net a while back. (Check your local or
neighborhood archives before broadcasting a request for it. I seem
to recall a couple of "bug fix" followups as well.)


Rob Warnock
Systems Architecture Consultant

UUCP:	{ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD:	(415)572-2607
USPS:	510 Trinidad Lane, Foster City, CA  94404

gvg@hp-pcd.UUCP (gvg) (04/07/85)

> I have heard rumors about a "free" "C" compiler called "small C", written
> by a fellow named Ron Cain.  

> Does anybody know much about this?  Does it run on UNIX systems?  Where 
> would I find it?

from: G.V. Goebel
date: Thursday, 4 April 1985

I got an overwhelming response on this note - thanks to everyone who dropped
me a line.

                                           Regards - GVG
                                           hplabs!hp-pcd!gvg

gvg@hp-pcd.UUCP (gvg) (04/08/85)

from: G.V. Goebel / Hewlett-Packard Corvallis Division
to:   All You Kind Folks
date: Saturday, 6 April 1985
re:   Thank You

That "overwhelming response" I mentioned earlier is continuing.  I would
thank everyone individually, but, unfortunately, it would simply take
me more time than I have available at the present.

So, I might as well thank everyone at once:

	- Rob Warnock
 	- Jerrold L. Gray
        - Dave Herron
	- Andrew Macpherson (all the way from the UK!)
        - Gino Bloch
        - Lee Thomas

Sad to say, "Small C" looks like a dead end for my own purposes.

I'm working in sales promotion for HP's new "Integral" portable computer,
and I managed to scrape up some public-domain stuff that came in handy and
maybe even got us some sales.  (Like many brand-new computers that are not
complete clones of the products of a certain Incredibly Big Manufacturer of
personal computers, we are hurting for software right now.)

We made a few sales by simply being able to provide the "Kermit" data
communications program to universities, for example.

When BYTE had its recent issue on public domain software, we picked up a
copy of Dave Betz's XLISP, which proved to be pretty well put together and
a lot of fun to play with.  (I have been teaching myself LISP with it.)
One article also mentioned "Small C" - hence my question.

While I was somewhat dissapointed that "Small C" wouldn't run on UNIX
without a lot more tweaking on my part than I had time to consider, it
has piqued my curiosity.  I'll probably end up running off a copy of the
article - if just to teach me more about how compilers work...

Again, thanks for the help.

					Regards - GVG
                                        hplabs!hp-pcd!gvg

PS: It was pleasant to see this civility after some of arguments I've found
myself getting sucked into on the Net.  I am new to the Net, and I was
surprised to find out that expressing the most idle opinions makes one fair game
for attack and invective.  (Sadly, the internal HP network is much worse in
this regard than the Net in general.)  I an half-tempted to post - in a
prominent place - a letter with the following statements:

	- The Pope is Catholic.
        - Bears live in the woods.
        - The sun comes up in the morning.
        - President Grant is buried in Grant's Tomb.

- and see if I get arguments over it ...

g-frank@gumby.UUCP (04/08/85)

> I an half-tempted to post - in a
> prominent place - a letter with the following statements:
> 
> 	- The Pope is Catholic.
>         - Bears live in the woods.
>         - The sun comes up in the morning.
>         - President Grant is buried in Grant's Tomb.
> 
> - and see if I get arguments over it ...

WRONG WRONG WRONG!

	- The Pope is Polish
	- Bears live in zoos and National Parks.
	- The sun goes down in the evening.
	- The President is Reagan.  You can't have dead presidents.

  so there!


-- 
      Dan Frank

	  Q: What's the difference between an Apple MacIntosh
	     and an Etch-A-Sketch?

	  A: You don't have to shake the Mac to clear the screen.

carl@hpcnoe.UUCP (carl) (04/13/85)

>	- The President is Reagan.  You can't have dead presidents.

Some might argue that the above is self-contradictory.

;-} I think


Carl Dierschow
Fort Collins, CO