cc65 is a C cross compiler for 6502 processor machines and derivatives. It's freeware (not open source though), the source code is available. It was originally written by John R. Dunning.

It has a library that supports Commodore computers (Commodore 64 and others), Apple II, Atari and some others. The library seems to include a Borlandese Curses-lookalike and a GEOS library...

Home page: http://www.cc65.org/ -- See also xa.


(Following is from my today's Advogato diary - about my first encounter with this compiler. Some errors corrected.)

My "Maze Hack Project" continues... today, the C64 project continued when I got cc65, a rather neat freeware C cross-compiler for 6502 processor family...

I had earlier made a C program that generates and solves mazes. It was written to be simple and compact because I wanted to port it to Commodore 64 assembly one day. I used this C thing to show myself the theory and practice of maze generation. (The generator uses randomness, "sets" and depth-first search to generate maze - not perharps too efficient, but it generates pretty neat mazes. The solver is just a depth-first search - the same what xmaze screen saver uses =)

The port hasn't happened (because I have had cooler things to do, and as with all other assembly-related things, "you need to invent the gun, bullets and powder first before you can shoot yourself to foot"). So, I decided to take this compiler and see what it does.

The only problem I had was that it didn't know what the heck time() does (there was a prototype in headers for that but no implementation in the standard library). I made a simple wrapper for it to take the time from clock() function instead (the time was only needed for the random number generator that sucked anyway). Then it compiled fine. And then...

I loaded it.

I ran it.

It did what was advertised.

I guess I know how to write more or less efficient and portable code - because under VICE, this thing generates the maze in about 8-10 seconds and solves it in about 1-3, both times seem fairly reasonable. And yes, it runs just as nicely as the real thing. =) Well, I guess the generator could use

The bad thing? The Linux binary was 6912 bytes - and the C64 binary was 7218 bytes. This is what we in the industry call "bloat". =( (Real Men Don't Need a "Library". =)

Now I have finally found a C compiler where I may find the asm(...); a joy to use. Assuming, of course, that this supports such things =)