scc6502 a version of small-c for the 6502 and LUnix Ivan A. Curtis 4-Jul-97 21:05 1. Introduction --------------- This file describes 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. Small-C has been around for a long time - see the SCC_README file for details. LUnix is a small Unix-like operating system for the commodore 64 microcomputer. See for details. 2. Compiling the Compiler ------------------------- This should be relatively straight forward with any unix system. In particular, I have been developing this under Linux with gcc. You will get many warning about mixing pointers and ints : don't worry about it. small-c is designed to compile itself! and is not as uptight as "real" c about the distinction between pointers and ints. Doing make scc6502 in this directory should get you the scc6502 executable. 3. Compiling and Running with programs on LUnix ----------------------------------------------- You will need the latest version of LUnix and the development tools. Some minor changes to luna are required to get clean assembly of the generated code. I have included patches to luna version 1.19 in the file luna.patch (unified diff). This file also includes some changes made by Daniel Dallman which brings it to version 1.20 (I hope this is OK Daniel?) To patch your luna.c , simply move luna.patch to the directory containing luna.c, and then do patch < luna.patch In the directory tests is a Makefile with rules to use scc6502 to compile some toy programs for LUnix. Your make probably thinks it already knows how to compile a .c file, so be sure to do make -r file.exe to get it to forget the explicit rules. Note that you must have the LUPO_INCLUDEPATH environment variable set correctly - see the LUnix tools documentation for details. The file crt0.S is a HAND GENERATED runtime support file. Do not blow it away, as every c program will need it to run! Once you have file.exe, you can run this on LUnix like any other executable. Try out hexdump.exe! 4. Limitations and Future Work ------------------------------ For the limitations of small-c, read SCC_README. You will also find limitations by running into them! For limitations of the code generator, please be aware that this is a very early release, and is still incomplete in many areas. Also, it has not been at all thoroughly tested, so bugs will exist. Firstly, some of the run-time support is incomplete. For example, the modulo routine is not implemented, and the division routine works only for unsigned numbers. Secondly, the code generated is pretty inefficient. Thirdly, libc is non-existent. I have made a little stdio.c, just enough to get the tests going. This is an area where help will be much appreciated. My ultimate aim is to get scc to the point where it can run on LUnix. The stripped gcc compiled executable on linux is around 30k, so this target seems feasible to me. I would be pleased to receive bug reports, and even more pleased to receive offers of assistance with development. Ivan Curtis icurtis@radlogic.com.au