The 6502

Programming the 6502 SBC using cc65


A bit raw but what matters is stated. I haven't had time to write a proper description on how cc65 really works so the necessary steps to get it working with the SBC are stated.
  1. Edit the Makefile in cc65/libsrc add hkh65 to the list of all targets.
  2. In the same file, append the following after f.x. the Vic20 part
    #-----------------------------------------------------------------------------
    # hkh65
    hkh65lib:
    for i in hkh65 common runtime conio zlib; do \
    $(MAKE) SYS=none -C $$i || exit 1; \
    $(AR) a hkh65.lib $$i/*.o;\
    done
    mv hkh65/crt0.o hkh65.o
    #-----------------------------------------------------------------------------
  3. Create a directory cc65/libsrc/hkh65 and add this Makefile to it.
  4. To the same directory, add crt0.s and delay_functions.s.
  5. In cc65/libsrc/hkh65 do make
  6. In cc65/libsrc do make
Now, if everything works well, we have created the library for the SBC, i.e. cc65/libsrc/hkh65.lib and cc65/libsrc/hkh65.0. We are now ready to start making some code for our computer. Using test.c as an example and the SBC configuration file hkh65.cfg
  1. cc65 test.c
  2. ca65 test.s
  3. ld65 -C hkh65.cfg -m test.map -o test test.o ./cc65/libsrc/hkh65.o ./cc65/libsrc/hkh65.lib
which should result in an empty file ram.bin and rom.bin which is ready to be burnt to an eeprom. However, if one looks at test.map, it states that the startup is at $C00C and this is where you should direct $FFFC and $FFFD to.