Chris Ward's 6502 Computer


The Circuit
Parts List
EEPROM Programmer
Related Links

Back to my Home Page

Created by Chris Ward
Last update 15/05/2007


--- This page is still being written ---


There are several 6502 cross-assemblers available. I personally use MAS65 by Douglas Beattie. It doesn't have as many features as some others, but it works well and produces Intel Hex files suitable for my EEPROM programmer. I have written a pre-processor for it - MAS65PP - which adds a #include directive, so you can split your project into multiple source files.

For development in C, the best cross-compiler appears to be cc65. I recommend that you ensure you have the latest version (currently 2.6) because several important bugs have been fixed. It comes with support for several 6502-based machines, mostly Commodores, but you need to write a small run-time library for other systems. As an example you can download my library (with source code) in, but remember that it depends on certain zero-page and ROM addresses which are defined in my BIOS. Here's some instructions for compiling programs using this custom library (assuming you've already set-up cc65 according to its instructions):

  • Copy cnw6502.o and cnw6502.lib to your cc65 library directory
  • Copy cnw6502.h to your cc65 include directory
  • Put cnw6502.cfg in the same directory as your C program
  • Compile your C program, e.g.
    cc65 hello.c
  • Assemble the resulting file, e.g.
    ca65 hello.s
  • Link your program with the startup code and library, e.g.
    ld65 -o hello -C cnw6502.cfg cnw6502.o hello.o cnw6502.lib
    (note: the order of the .o and .lib files is important)
  • You now have an executable called 'hello' which you can load into the 6502 by whatever method you prefer. The start address is $1000, as defined in the cnw6502.cfg file.


Click here to download the source code for the computer's BIOS. To build the BIOS you need to process BIOSMAIN.ASM with MAS65PP and assemble the output with MAS65.

Some notes about using the BIOS:

  • After the memory test, it detects the hard disk. It will freeze at this point if you do not have a hard disk attached.
  • When the hard disk has been identified, its model number will be displayed. Press a key on the keypad to continue. The next display shows the following values (in hex): cylinders, heads, sectors per track, sectors per cylinder, total number of sectors, drive access mode (CHS or LBA). Press a key to continue to the main menu.

Some technical notes about the BIOS:

  • The DS1687 RTC is programmed to produce an IRQ interrupt 256 times per second. On each IRQ, the keypad is scanned and the zero-page variable 'TI_TICK' is incremented. Hence TI_TICK can be used as a timer with 3.9ms precision.
  • Each time TI_TICK overflows (i.e. once per second), the full time and date is read from the RTC into zero-page registers.