André's 8-bit Pages  Projects  Code  Resources  Tools  Forum
(by Google)

6502 Software Compatibility Notes

Here are some notes on compatibility with the 6502.

The 65002 is binary compatible with the 65C02 - except for minor quirks required for the extension, as described on this page.

The 65k has, on purpose, an extended interrupt functionality. Thus it needs an extended stack frame to store the additional information, as described above. Yet there is 6502 compatibility included:

Stack Frames
Address650265k
S+10ADDR byte 7
S+5..9 ADDR byte 2..6
S+4 ADDR byte 1
S+3ADDR byte 1ADDR byte 0
S+2ADDR byte 0Extended Status Byte
S+1Status register (bit5=1)Status Register (bit5=0)

As you can see it is the status register bit 5 that determines whether an extended stack frame is used or not. In a 6502 it is always 1. As a result, if some 6502 software creates an artificial stack frame with bit5 cleared, it will trigger the use of an extended stack frame and crash.

A similar result will happen on a PLP, as PLP reads the extended status register if in the normal status register on the stack bit 5 is zero (The extended status register has the G and OE flags that are available from user mode. All other bits are set to zero)

As the 65k has an extended interrupt functionality, the number - and size - of the 6502 interrupt pointer does not suffice anymore for an efficient operation.

For compatibility reasons the CPU starts with a restricted set of 6502-compatible interrupt vectors as described above. Only when the Interrupt Base Register is set, the extended, per interrupt jump vectors are used.

When the processor starts, it starts in hypervisor mode and the compatible interrupt vectors. Interrupts stay in hypervisor mode and the only incompatibility is the extended stack frame.

The 65k can be configured in 16, 32 or 64 bit width. Thus a return address for a subroutine is 16, 32, or 64 bit wide. Only a 16 bit wide return address is compatible though.

The user mode configuration register however allows to restrict the effective processor address width to 16 (or 32) bit. In this mode the return address is restricted to 16 bit, and the real address is extended with the upper bits (16-31/63) of the program counter.

The 65k will NOT be timing compatible with the 6502.

Although one might think of using an 8-bit accumulator and the typical 6502 pipelining to extend the original 6502, this is not the goal of this design. The goal is to venture into wider address and data bus sizes, and also use wider accumulators, to effectively use the available features of today's programmable logic. So this makes it very unlikely, if not impossible, that a timing-compatible 65k will ever exist.

 

Disclaimer

All Copyrights are acknowledged. The information here is provided under the terms as described in the license section.

Last updated 2013-11-17. Last modified: 2013-11-17
follow

Follow my 8-bit tweets on Mastodon (In new window) or Bluesky

discuss

Discuss my site on this 6502.org forum thread

(Forum registration required to post)

hot!

Dive into the retro feeling and build yourself a Micro-PET or a Multi-board Commodore 4032 replica

Need more speed? Speed up your 6502 computer with this 10 MHz 6502 CPU accelerator board

Interested in electronics design? Look at the design lesson I got from Bil Herd, the hardware designer of the C128

Want 64bit? - pimp the 6502 with the 65k processor design!