EtchedPixels / CC6303

A C compiler for the 6800 series processors
Other
37 stars 7 forks source link

CC6303

A C compiler for the 6800/6803/6303 processors

This is based upon cc65 [https://github.com/cc65/cc65] but involves doing some fairly brutal things to the original compiler. As such I currently have no plans to merge it back the other way.

In particular cc65 has a model where the code is generated into a big array which is parsed as it goes into all sorts of asm level info which drives optimizer logic. It also uses it to allow the compiler to re-order blocks and generate code then change its mind.

Status

The basic structure is now reasonably functional. You can "make" and "make install" to get a complete compiler/assembler/linker/tools that appear to generate actual binaries.

The assembler and linker should be reasonably reliable and complete. The compiler at this point should be reasonably solid on 6803 and 6303 except for 32bit types. The core compiler support for 32bit types is there and mostly tested but the library helpers for shifts, multiply and particularly division are not yet fully debugged.

On the 6800 processor the library routines are far from complete. Note that the 6800 target will generate much slower and larger code because the 6800 lacks 16bit operations and some other important features. 6800 code is about a third larger.

The bundled C library routines are initial code and not fully tested or reviewed. They are intended to provide native versions of key and time critical functions not a full C library.

How to use

For a simple test environment the easiest approach at this point is to compile the code with cc68 and then link with a suitable crt.o (entry code)

cc68 -m6803 -c foo.c
ld68 -b -C startaddress crt.o mycode.o /opt/cc68/lib/lib6803.a

Tandy MC-10 target

cc68 -tmc10 foo.c -o foo

This will produce a foo.c10 that can be loaded into an emulator or turned into a wav file. A few minimal C library functions are present including putchar/puts.

TODO

BIG ISSUES

    ldx $foo
    inx
    stx $foo
    dex