Main Page


Contents

* Overview
* Compiler features
* Other tools
* Supported Targets
* Host Systems
* Docs and Samples
* Copyright
* Download
* Links
* Feedback
* Mailing list
* Credits
* Frequently asked questions (last updated 23-Mar-2001)
* Known bugs (last updated 22-Mar-2001)
* News (last updated 22-Mar-2001)
* Development page




Overview

cc65 is a C compiler that was originally adapted for the Atari 8bit computers by John R. Dunning. It is a Small C descendant but has several extensions, and some of the limits of the original Small C compiler are gone. The original copyright allows free redistribution including sources, even if it would not qualify as Open Source Software according to the Open Source Definition.

The original Atari compiler is available from http://www.umich.edu/~archive/atari/8bit/Languages/Cc65/. The complete package consists of the compiler, an assembler, a librarian, a linker, and a C library for the Atari. There are some packages on the net that claim to be adapted as a crosscompiler for DOS or Unix, but was not able to get them working correctly.

Because I wanted a C compiler for my CBM machines, I took the Atari compiler and started a rewrite. Until today, I have rewritten large parts of the compiler, all of the library, completely replaced the assembler, the linker and the librarian, and added a frontend to simplify use. All changes have been done with portability in mind, so porting to new 6502 architectures should be quite easy.


Compiler Features

The compiler is almost ISO C compatible, so you should be able to translate many sources from other systems. Here is a list of the differences:

* The compiler allows single line comments that start with //. This feature is disabled in strict ANSI mode.
* The compiler allows unnamed parameters in parameter lists. The compiler will not issue warnings about unused parameters that don't have a name. This feature is disabled in strict ANSI mode.
* The compiler has some additional keywords that are needed for special features. In strict ANSI mode, the additional keywords start with two underscores.
* The "const" and "volatile" modifiers are available, but have no effect.
* The datatypes float and double are not available.
* The compiler does not support bit fields.
* Initialization of local variables is only possible for scalar data types (that is, not for arrays and structs).
* Because of the "wrong" order of the parameters on the stack, there is an additional macro needed to access parameters in a variable parameter list in a C function.
* Functions may not return structs. Struct assignment is possible.
* There are some limitation on the size of local variables. Not all operations are available if the size of local variables exceeds 256 bytes.
* Part of the C library is available only with fastcall calling conventions (see below). This means, that you may not mix pointers to those functions with pointers to user written functions.

There may be other target system dependent limitations. One example is file I/O, which is currently only implemented for the Atari machines. This is no technical limitation (as with the stuff mentioned above) but does just mean that no one cared enough to write the actual code.


Other tools

The compiler is only one of the tools available in this package. The assembler suite (assembler, linker, archiver) is a complete development environment for itself, that may be used to write programs for any 6502 machine. C code and assembler code may be used together and may call each other.

The assembler is a one pass macroassembler and is able to output code for the 6502, the 65SC02 and 65SC816. It has a lot of nifty features like include files, conditional assembly, macros, nested lexical levels (that is, local symbols), and more. The assembler creates object files containing relocatable code. These files must be run through a linker to create the final program.

The linker has a flexible output format and is able to support ROMable code (different load and run addresses for data), banked systems (segments may share the same run address), systems with multiple ROMs, unlimited segments, more than one BSS segment and lots of other things.

The archiver is used to create libraries containing objects files. This simplifies code management. The linker will extract only those modules from a library that are actually needed.

To simplifiy use, there is also a frontend to the tools contained in the cc65 package. The frontend is named cl65. It knows how to build binaries from a list of C files, assembler files, object files and libraries. For smaller projects, just one invocation of the cl65 utility is needed to build a binary from several source files and libraries.


Target Systems

The runtime library and the standard C library have been designed with portability in mind. Changes for any 6502 system shouldn't be necessary. If you have a system not listed below, all you need is a new startup code.

Direct library support (that is, startup/initialization code) and support libraries for other features are available for...

* ...the Commodore C64
* ...the Commodore C128
* ...the Commodore C16, C116 and Plus/4
* ...the Commodore 600/700 family of computers
* ...the Apple ][
* ...the Atari 8bit machines

Especially the CBM 600/700 are very nice targets, since the programs created by cc65 run in a separate memory bank and have almost FULL 64K of memory available!

The apple2 port was done by by Kevin Ruland, kevin@rodin.wustl.edu.

The port back to the Atari machines was contributed by

Christian Groessler, cpg@aladdin.de
Mark Keates, markk@dendrite.co.uk
Freddy Offenga, taf_offenga@yahoo.com
David Lloyd, dmlloyd@atari-central.com


Host Systems

With one exception in the compiler (access()) the code is plain ISO C, so it should compile on most systems. Memory usage may be a problem, however.

I'm providing full sources and binaries for the following systems:

* Linux: This is the primary development platform, so the sources should compile out of the box under Linux. Binary and source RPMs for RedHat Linux are available.
* DOS: The binaries are compiled with the Watcom compiler and use the DOS4G/W extender.
* OS/2: There are very few downloads for this version, so while it is still available, it may get removed soon.
* Windows NT and 95/98: Watcom compiled binaries.

Apart from that, I have reports that the sources compile under the following platforms with none or only minor changes:

* FreeBSD (report from Tim Vanderhoek <hoek@FreeBSD.org>).
* DOS using DJGPP (report from Keith W. Gerdes, <kwg@netzero.net>, see compile.txt for some notes).
* Windows NT using VC++ (report from Bill Craig <craigw@gusun.georgetown.edu>).
* BeOS using gcc as C compiler (report from Arvid Norberg <c99ang@cs.umu.se>).
* Irix 6.5 using gcc (tested that myself, compiles out of the box).


Docs and Samples

About 600K of documentation in HTML and ASCII format is available, describing the compiler and the other tools.

Please note, that there is nothing in the documentation that will teach you C! If you have never programmed in C before, your first action should be to get a good book. The documentation files cover invocation of the programs, special features and differences to the standard, some internal workings and a step-by-step intro.

The docs are included in the distribution packages and are also available online.

The distribution packages do contain some sample programs that may be used as a first starting point:

* hello.c is a simple hello world style program using the conio library.
* sieve.c is an implementation of a popular benchmarking program.
* nachtm.c runs on machines with a SID only. It plays "Eine kleine Nachtmusik" by W. A. Mozart.

Code from the sample programs may be freely used in your own programs.


Copyright

This is the original cc65 compiler copyright:

  -*- Mode: Text -*-

     This is the copyright notice for RA65, LINK65, LIBR65, and other
  Atari 8-bit programs.  Said programs are Copyright 1989, by John R.
  Dunning.  All rights reserved, with the following exceptions:

      Anyone may copy or redistribute these programs, provided that:

  1:  You don't charge anything for the copy.  It is permissable to
      charge a nominal fee for media, etc.

  2:  All source code and documentation for the programs is made
      available as part of the distribution.

  3:  This copyright notice is preserved verbatim, and included in
      the distribution.

      You are allowed to modify these programs, and redistribute the
  modified versions, provided that the modifications are clearly noted.

      There is NO WARRANTY with this software, it comes as is, and is
  distributed in the hope that it may be useful.

      This copyright notice applies to any program which contains
  this text, or the refers to this file.

      This copyright notice is based on the one published by the Free
  Software Foundation, sometimes known as the GNU project.  The idea
  is the same as theirs, ie the software is free, and is intended to
  stay that way.  Everybody has the right to copy, modify, and re-
  distribute this software.  Nobody has the right to prevent anyone
  else from copying, modifying or redistributing it.

In acknowledgment of this copyright, I will place my own changes to the compiler and other executable sources under the same copyright.

The library and the binary utils are a complete rewrite done by me and covered by the following license:

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.


Download

There are several versions available for download.

Please note that the FTP server is somewhat picky: Your host needs to have a correct DNS entry (forward and reverse mapping), and a valid RFC822 address is expected as the anonymous password. If you cannot connect to the server your DNS entry is probably not ok, if you get an error message about an invalid password, you have to enter your correct email address or (if you're using a WWW browser to connect to the server) configure your browser correctly. In Netscape, this is in Preferences/Advanced: Check the box "Send email address as anonymous FTP password" and make sure that the browser knows your email address.

If you're interested in the latest version, you may want to have a look at the daily snapshot of the CVS archive. Beware: Since this is a daily copy of the sources from the CVS repository, these sources may not even compile! My development platform is Linux. If you're in real need of a new version, your best chances are using Linux, too.

Arvid Norberg, <c99ang@cs.umu.se> has setup a HTTP mirror for the cc65 archives. If you have problems with the MU software FTP server, or if you prefer HTTP over FTP, you may want to give it a try.


Links

Rainer Buchty discussed cc65 in his monthly GO64 column "World Watch". The article (in German!) is now available online.

There's another extended version of the original cc65 compiler at http://www.geocities.com/SiliconValley/Byte/4242/lynx/cc65.html I did not have a look at the code until now, but I had some discussions with the author, and he has implemented some cool things like register variables. The port doesn't support any targets besides the Atari Lynx.

There was an announcement for another C compiler named Quetzalcoatl some time ago in comp.sys.cbm. The compiler seems to be rather limited (no pointers, no structs, no longs...), but that may change, so have a look yourself.

And then, there's a actively developed port of lcc to the Super-CPU (the SCPU is a 65816 accelerator card for the C64/C128 clocked with 20MHz). This compiler too needs some work to be really usable, but Jolse is working on it.

Finally, the 6502 lcc port seems to get real - or not. Have a look yourself!

When debugging your programs, an emulator is a real nice thing. VICE emulates many different CBM computers and runs under Linux. Versions for other platforms are also available from the above web page (for more information about the VICE OS/2 port look here.) I've used VICE to debug parts of the runtime library and for the CBM 610 port. Apart from that, the ld65 linker is able to create a label file for VICE, so you see all label names of your program (even the local ones!) in the VICE machine language monitor.


Feedback

I'm very interested in feedback. If you have any questions, experiences or suggestions, send me a mail. You may also consider to subscribe to the cc65 mailing list (see below). Please note that I cannot answer C programming questions that are not specific to the cc65 C compiler implementation.

If you have problems, please have a look at the list of known bugs before mailing me.


Mailing List

There is a mailing list for discussion of cc65 related problems, ports, and announcements. To subscribe to the list, send a mail to majordomo@musoftware.de with the text

subscribe cc65
in the body of the mail. Please do not use MIME encoding, HTML or other stuff, since this will confuse majordomo (which is only a perl script parsing your mail).

www.appwatch.com has an archive of the mailing list starting december, 2000.


Credits

Many people have helped to make cc65 what it is today, and there are times when I receive bug reports, suggestions and even contributed code almost daily. A big "Thank you!" to you all!

Unfortunately, any list on this page would be outdated at the time you read it. I'm trying hard to keep the CREDITS file, that comes with the distribution up to date. You may want to have a look at the current version.



Valid HTML 4.0! index.php; last change: 08-Mar-2001
webmaster@cc65.org