⭅ Previous (Trying Higher Speed Chips)

Supporting the 65816 CPU in the Chiplab

A hardware perspective.

Welcome. In this post we’ll look at supporting the 65816 CPU in our hardware research platform, the Chiplab. If you’re new to this series, you might find the additional context from earlier articles helpful. Find out more at the Chiplab home page.

While we have a 6502 supported in the lab, we would like to generalize this to support many other types of integrated circuit. While we discovered last time that there are some challenges in supporting NMOS chips, there are many more chips we can support with our existing design. The 65816, the 16 bit successor to the 6502, is similar enough to the 6502 that we can support it in the lab without too much difficulty. Now lets dig in to exactly what it takes.

About the 65816

The 65816 was conceived of as a 16 bit successor to the 6502. While the 6502 was used in systems like the Apple][ and the NES, the 65816 was used in the Super Nintendo and the Apple IIGS.

Since the 6502 was used in many successful systems, similarity to this existing chip was a key design consideration. Lets compare the pinouts for the 65816 and the CMOS version of the 6502 which we already have in the lab.

6502 and 65816 pinout

Sources:

We see there are only a few differences, so only a few things need to be updated:

The remaining differences are unused outputs, which can be safely ignored.

Patching the 6502 PCB

As suggested above, we need to make only two changes to the circuit board we originally designed for the 6502. Desolder one of the pullup resistors, and connect the abortb to power to ensure instructions aren’t aborted.

patches: desoldered resistor and power

Testing the modified board

With the board modified, it is time to test. Fortunately, the software design for the 65816 is also designed for compatibility. The name of the chip even suggests that is is both an 8bit and a 16 bit CPU. When the chip first resets, it starts up in “emulation mode”, an 8 bit mode capable of running unmodified 6502 programs.

We can check that the 65816 is functional by running an existing 6502 program against this chip. By reusing the countdown program and observing the data and address buses, we can confirm that its working.

; write values from 0x10 to 0x00 to address 0xCAFE
.reset:
  ldx #$10
.countdown:
  stx $cafe
  dex
  bne .countdown

.loop:
  jmp .loop

.nmi:
  rti

.irq:
  rti

; interrupt vectors
org $FFFA
dw .nmi
dw .reset
dw .irq

Output snippet:

a=0x0003 rwb=1 sync=1
a=0x0004 rwb=1 sync=1
a=0xCAFE rwb=0 d=0x0F sync=0
a=0x0005 rwb=1 sync=1
a=0x0006 rwb=1 sync=0

65816 in the Lab

And now the 65816 is available in the lab for anyone to access.

The online assembler doesn’t yet support 65816 instructions. As a workaround, you can insert 65816 instructions in your program by inserting the corresponding bytes via db and dw.

65816 assembler updates are coming soon, and a future article will cover the non-emulation mode of the 65816 in more detail.

⭅ Previous (Trying Higher Speed Chips)

We publish about 1 post a week discussing emulation and retro systems. Join our email list to get notified when a new post is available. You can unsubscribe at any time.