scc - a C compiler (from 1987, for C64 and LUnix)

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

scc - a C compiler (from 1987, for C64 and LUnix)

Post by BigEd »

I was searching for Small-C information (it seems that cc65 is descended from Small-C) and found this:

http://www.reocities.com/SiliconValley/ ... cc6502.tgz
http://www.reocities.com/SiliconValley/ ... cc6502.txt
Quote:
a version of small-c for the 6502 and LUnix [by] Ivan A. Curtis
Quote:
scc6502, a version of the small-c compiler for the 6502, specifically designed for the C-64 running the LUnix operating system. Changes to the assembly syntax and the runtime will allow it to be used for other 6502 systems.
From the included SCC_README file:
Quote:
Small C version C3.0R1.1 (SCC3) [by] Chris Lewis

This directory contains the source for a version of Ron Cain's Small C
compiler that I have heavily modified - beyond the Small-C V2.0 later
published in Dr. Dobbs. This compiler generates assembler source code that
needs to be assembled and linked to make a running program.
In a similar vein, see also this $30 CD of info from Dr Dobbs:
Quote:
The CD-ROM includes James Hendrix's out-of-print book, A Small-C Compiler: Language, Usage, Theory, and Design, and several relevant articles from Dr. Dobb's Journal written by C experts such as Allen Holub.
Tangentially relevant, there's a doc by Edmund Grimley-Evans describing the bootstrapping of a C compiler, albeit on x86 and assuming ELF format executables:
Quote:
Bootstrapping a simple compiler from nothing
============================================

This document describes how I implemented a tiny compiler for a toy
programming language somewhat reminiscent of C and Forth. The funny
bit is that I implemented the compiler in the language itself without
directly using any previously existing software. So I started by
writing raw machine code in hexadecimal and then, through a series of
bootstrapping steps, gradually made programming easier for myself
while implementing better and better "languages".
Seen also on github (uploaded by Scott Taylor)

More bootstrapping references in this discussion.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by BigEd »

BigEd wrote:
I was searching for Small-C information
...
see also this $30 CD of info from Dr Dobbs:
Quote:
The CD-ROM includes James Hendrix's out-of-print book, A Small-C Compiler: Language, Usage, Theory, and Design, and several relevant articles from Dr. Dobb's Journal written by C experts such as Allen Holub.
The CD-ROM in question can be found at the Internet Archive, and for convenience I've unpacked it into a repo here.

I notice there are versions for many micros, and the 6502 version by Dr A.J. Travis is specifically for the BBC Micro. There's a sideways ROM for the runtime.
Quote:
Small-C is a subset of the C programming language for which a number of public-domain compilers have been written. The original compiler was written by Ron Cain and appeared in the May 1980 issue of Dr.Dobb's Journal. More recently, James E.Hendrix has improved and extended the original Small-C compiler and published "The Small-C Handbook", ISBN 0-8359-7012-4 (1984). Both compilers produce 8080 assembly language, which is the most popular implementation of Small-C to-date. My 6502 Small-C compiler for the BBC Micro is based on "RatC", a version of the original Ron Cain compiler described by R.E.Berry and B.A.Meekings in "A Book on C", ISBN 0-333-36821-5 (1984). The 6502 compiler is written in Small-C and was bootstrapped using Zorland C on an Amstrad PC1512 under MSDOS 3.2, then transferred onto a BBC Micro using Kermit. The compiler can be used to cross-compile 6502 code from an MSDOS host, or as a 'resident' Small-C compiler on a BBC Micro.
(The CD-ROM and therefore the mirror repo also contain the text of the book and a collection of articles related to Small-C taken from Dr. Dobb's.)
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by BigDumbDinosaur »

Back in the 1980s, there was the Power C compiler (aka the “Better Working” compiler, unrelated to the later MIX product) that would run on a Commodore 64 or 128, with the latter running in either mode.  I recall that a Canadian programmer was the one who developed it, but his name escapes me.

Power C worked best with either dual floppy drives, or a hard drive subsystem, e.g., the Xetec Lt. Kernal—using it with one floppy drive turned the usual development cycle into a tedious exercise of constantly changing disks.  I’ve never been a big user of C, but did fool around with Power C on my C-128D when I was designing the truck leasing system, hoping to not have to wrote the entire package in assembly language.

The compiler worked okay and when it issued diagnostics during compilation, they made enough sense that tracking down the source of the error wasn’t difficult.  Compilation was not a speedy process, of course, but not too bad on my Lt. Kernal-equipped development system.  In the end, I went 100 percent assembly language because binaries generated by the compiler had a lot of boilerplate attached and didn’t run fast enough in what was designed to be a multiuser system.

I wonder what became of that compiler.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
barnacle
Posts: 1831
Joined: 19 Jan 2004
Location: Potsdam, DE
Contact:

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by barnacle »

Looks like it hasn't been sold in twenty years... https://www.c64-wiki.com/wiki/Power_C

Neil
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by 6502inside »

Power C was from ProLine (Jim Butterfield/Brad Templeton/Steve Punter's outfit). But I've never found C or other stack-based languages a good fit on the 6502. I think I'd only reach for it if it didn't need to be assembly-fast but faster than BASIC, and/or assembly would be inconvenient to write the algorithm in.
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by BigDumbDinosaur »

6502inside wrote:
Power C was from ProLine (Jim Butterfield/Brad Templeton/Steve Punter's outfit).
Ah, yes...now I remember ProLine.  They used to regularly run ads in Transactor, with the three of them wearing (Canadian) football helmets.
Quote:
But I've never found C or other stack-based languages a good fit on the 6502. I think I'd only reach for it if it didn't need to be assembly-fast but faster than BASIC, and/or assembly would be inconvenient to write the algorithm in.
Yep!  Lack of a good means of using the stack for parameter-passing and storing local variables was a real dagger in the heart of C’s performance on the old 8-bitters.  When I found myself patching in custom machine code to get better performance, I came to my senses and put away the C compiler.  :D
x86?  We ain't got no x86.  We don't NEED no stinking x86!
orac81
Posts: 53
Joined: 20 Apr 2024
Location: uk

Re: scc - a C compiler (from 1987, for C64 and LUnix)

Post by orac81 »

I did see a really old ad in BYTE for a 6502 version of Small C for the KIM on Paper tape!

I remember tinkering around with Super C for the c64 or c128, I did benchmark it, now cant remember the results! I think it was comparable to Abacus Basic64/128, which was one of the better basic compilers. It presented a simple unix type shell for working
But most of the Small-C Compilers promote 8 bit ints to 16 bits, which generates big, slow code. VBCC and Oscar64 perform much better optimisation if you use BYTE instead of ints for variables that can be 0-255.
Post Reply