Close
0%
0%

W65C816SXB investigation

Evaluating the W65C816SXB development board

Similar projects worth following
A look at the W65C816SXB development board, as a starting point for new projects.

I bought this out of curiosity, to have a working 65C816 system.

With hindsight, I realise that the main use old processors is to run old software, and few machines used this one. Notable exceptions are the Apple IIGS and the Acorn Communicator, both of which were quickly obsoleted. If you wished to clone either machine, you would also have to clone their ASIC chips.

As a processor, I don't like it. It effectively has two modes and you have to know which one is in use when disassembling. The bus cycle timing is tighter and more complex, which means that many circuits for the 65C02 might not work.

WDC65c02SK_v2-0-4-3_2013-07-02.s.txt

Rough disassembly of 65C02 based board. Easier to see what is going on here than in the 816 firmware.

plain - 200.51 kB - 04/06/2021 at 23:09

Download

WDC65c02SK_v2-0-4-3_2013-07-02.info.txt

Rough disassembly information file

plain - 7.45 kB - 04/06/2021 at 23:09

Download

WDC65c816SK_WDCMON.s.txt

Rough disassembly

text/plain - 18.99 kB - 03/17/2021 at 01:23

Download

WDC65c816SK_WDCMON.info.txt

Information file for the da65 disassembler to roughly examine the firmware. The 65C02 code disassembles okay, but the 68C816 code does not.

text/plain - 8.93 kB - 03/11/2021 at 15:19

Download

WDC65c816SK_WDCMON.bin

W65C816SXB firmware backup, just in case I need to restore my ROM. Resides in top 32K of the 128K chip.

octet-stream - 32.00 kB - 03/11/2021 at 15:15

Download

View all 7 files

  • Firmware examination

    Keith03/10/2021 at 17:14 0 comments

    2021-03-09

    Read the development board firmware ROM and had a go at disassembly to get an idea of how it works. I used da65 from the cc65 suite, but this can only disassemble 65C02 code. The firmware is part 65C816 code, so that code disassembles incorrectly. 

    Although the firmware reserves 32K of the ROM, much of it is blank (0xFF) so the actual code is only about 1.6 K.

    It looks like the USB-interfacing VIA does not use the timers or interrupts, just polled. I need to check the VIA PCR register initialisation code to ascertain this.

    2021-03-18

    Disassembled code did not reassemble using '816-capable assemblers. Gordon Henderson provided the answer. Disassembly to 65C02 code produces some instructions that are not 65C816 instructions. My assumption that the 65C816 instruction set was an inclusive superset of the 65C02 is false!

    All the BBSn and BBRn are 'C02 instructions that have been replaced with other codes on the C816.

    Some hand disassembly later, I have some 65C816 source code that assembles. I have uploaded it.

    2022-05-12

    Timothy Alicie, a chap with more skills and time than I have, has started from my files and done a full disassembly including identifying which bits are native 65C02 or enhanced 65C816. There are versions to assemble using cc65 and other assemblers, plus relocatable or enhanced versions.

    See https://github.com/timali

  • Installing software tools

    Keith02/26/2021 at 02:37 0 comments

    2021-02-25

    Following instructions from here: https://wdc65xx.com/gettingstarted/816-sxb-getting-started/

    1. Download WDCTools Install WDCTools and set update preferences with the installer

    2. Download D2XX FTDI Driver

    3. Download the WDC Programming Manual (not required, but helpful resource)

    4. Download XLEDFLASH project (unzip into C:/wdc/W65C816SXB

    Done. Alas it is Windows only, so I hade to install on a spare i3 laptop instead of my i7 desktop.

    Now Find WDCTools Support  videos on YouTube

  • Porting BBC BASIC

    Keith02/21/2021 at 02:50 0 comments

    At first sight, this doesn't look too hard.  I have already hacked BBC BASIC for the Acorn second processor 6502, to run on an experimental 65C02 board. The only I/O is through the USB channel, and that is trivial. 

    There is a thread on stardot.org.uk about BBC BASIC on the 65816. Seems it has been done for the Acorn Communicator but not very well, perhaps to meet deadlines.

    https://stardot.org.uk/forums/viewtopic.php?p=298640#p298640

    I don't have time to modify the BASIC to take advantage of the 65816 instruction set and expand the built-in assembler, but it should run pretty fast.

    http://mdfs.net/Software/BBCBasic/BBC/Basic4.zip is for the 65C02, which uses a subset of the 65C816 instruction set.

    2021-02-24

    Discovered John Kortink has ported a 65C816 BBC BASIC onto his soft 65C02 second processor for the BBC micro. This is closed source, though if you had one running you could peek all the code bytes and disassemble them to analyse the firmware modifications.

    2021-02-25 

    My DE0-NANO FPGA and W65C816SX development boards arrived. I could do the porting work in the FPGA, but I don't want to wait for the CPU core to be compiled every time I make a tiny software mod. So I have installed all the new Western Digital development tools.

    2021-03-02

    After emailing some big names of the 6502 world, I learned from the very long thread about it: https://stardot.org.uk/forums/viewtopic.php?f=2&t=21159 it seems that the main guy working on 65816 BASIC is Dominic Beesley who has a disassembly here https://github.com/dominicbeesley/CommunicatorBasic100 which has a fair few source files.

    Looks like this is not a trivial job, if better programmers than me are having to work hard.

    The assembler now handles all 65816 instructions, which is good. The software is purported to be ... inelegant for want of a better word. It has to deal with short and long addressing, the overhead of using a separate 'module' for arithmetic, and other stuff.

    At this point I wonder if it is what I like about the 6502 - a well-known instruction set and architecture that is easy to use. Should I just port a simple 6502 BBC BASIC and then leave the potential of the 65816 modes to programmers with the time to harness it? Off the top of my head, I can't think of anything I would want a massive memory map. Maybe a memory-based disk system? Lots of graphics memory? I do big jobs on my PC and the development board does not have graphics. My spare time is scarce and my hobby projects are therefore fairly small.

    The Communicator BASIC includes code for running all the BBC micro I/O such as keyboard, disks, screen etc. A tube version would be simpler and smaller, and indeed there is a thread about this for an FPGA version https://stardot.org.uk/forums/viewtopic.php?f=3&t=9975. Looks like a better starting point for me.

    John Kortink has firmware for his 6502 second processor that uses a real ULA, 65C02/65C816 and a CPLD. It is obtainable from here: http://www.zeridajh.org/hardware/reco6502/updates.htm

    2021-03-03

    After reading the manual and some disassembly work, I have a better idea of what it does and how. The BASIC is modified have extra commands to configure the system through calls to a modified MOS.

    The configuration is loaded in a shift-register fashion. It is write-only, so I might be able to run his firmware and have the hardware simply ignore the shifted bits. If I can't use the configuration commands, then I might as well start from the unmodified 2nd processor BASIC and MOS.

    The master clock is 44.2638 MHz, which can be divided to nice baud-rate generator compatible frequencies.

    I have only disassembled the 65C02 version, using the da65 tool from the cc65 suite. 
    Alas it does not disassemble 65C816 code. Or compile C to 65C816 code either. I am inclined to implement just a plain 65C02 BASIC and let other people implement a 65C816 version if they have...

    Read more »

  • Purchasing

    Keith02/19/2021 at 03:25 0 comments

    2021-02-17 10:54

    W65C816SXB ordered from Tindie, for $68.16 plus £15 postage US to UK. Much cheaper than Mouser who were charging £111.48 including postage. 

    2021-02-17 19:16 Item dispatched! 

    2021-02-19 11:15 Item leaves USA!

    2021-02-24 21:19 Item clears customs and enters Royal Mail network.

    2021-02-25 Item arrives. Yay!

View all 4 project logs

Enjoy this project?

Share

Discussions

6502addict wrote 10/07/2023 at 10:39 point

I bought this board, but the development system is awful, I analyses the rom and replaced the original content of the eprom by my own monitor... the usb serial fifo is extremely fast it"s a dream to upload or download a hex or srecord file.....

I also found a nasty bug in 6502 emulation mode

if you try:

     LDA #$FF

     STA $40

     STA $41

     LDY #$02          

     LDA or STA  ($40),Y

     RTS

it irremediably fail on the LDA or STA

a 6502 would wrap and access a byte in page 0 bank 0

but the 65c816 does not wrap and try to access page 0 bank 1

were there is no memory so it fails....

I checked the schematics of the board the bank register is loaded

in a latch at some phase of phi2

in emulation mode it should load '00' to wrap like a 6502

I'm working on a board to analyses this bug....

I will try to fix it but I have no idea if keeping the bank register at 0

has side effect in emulation mode....

  Are you sure? yes | no

Keith wrote 10/07/2023 at 13:11 point

Thanks for the tip. To be fair on WDC, it really is a well known issue since the first days of the 6502, so WDC didn't bother to mention it in their documentation. Experienced 6502 programmers avoid this, which is easy enough. I can't think of a situation where someone would need to do this, apart from testing whether you have a 6502 or 65816.

The main use for the 6502 is running old 6502 software. There is very little 65816 software in comparison. It is an interesting curiosity, but I don't feel enough motivation to do anything more with it.

I am interested in seeing what your replacement monitor looks like. Perhaps that could be a project for you?

The USB interface is fast but I feel it is a bit kludgy having to bit-bang the control signals. I'd like to develop some logic so that it is memory-mapped and can thus run faster with less handshaking code. I've started doing this on my STEbus 6502 project.

It is possible to map the status flags to look like a 6850, but they are not in the best place for 6502 operation. Mapping the status flags to bits 7 and 6 allows them to be tested by the BIT instruction, without affecting the A register. The savings will be significant when transferring large blocks of data.

I made my USB module look like one channel of the Acorn Tube interface. 

  Are you sure? yes | no

6502addict wrote 10/08/2023 at 18:20 point

I don't know if it's a well known issue, but I never got any information about this bug from WDC.... I lost days thinking it was a bug in my code... I checked my code on my replica 1 and it worked fine... I was thinking about a software fix but it's not serious we can't check this condition before each LDA/STA indexed


I'm working with a similar FTDI chip to make a MP-S (SWTPC board) using a Serial USB FIFO  my board will be totally compatible with the MP-S I'll use a CPLD to map the register / flag of the FTDI chip as if they were a real 6850

I think a hardware solution exist by taking into account the E flag while loading the latch [I'll soon be able to test it, I build a 65c816 board with 512k 32k rom and the glue logic in an EPM7128S this way I'll be able to test several solutions just by reprogramming the CPLD]

  Are you sure? yes | no

Peabody1929 wrote 03/19/2021 at 23:15 point

I bought this board but never used it.  Your article inspired me to "fire it up".  I use Tera Term on my PC and connect via USB to the board.  However, I can not find any information about how to configure the serial port in Tera Term.  What settings do you use?  I appreciate the help.  Thanks.

  Are you sure? yes | no

Keith wrote 03/20/2021 at 01:28 point

From the quick disassembly, the firmware doesn't seem to initialise anything apart from the VIA operating the USB FIFO module. This talks to the Terbium IDE program. From there you can single step or animate code. USB doesn't need settings like  baud rates, stop bits and so on.

  Are you sure? yes | no

stephencass wrote 03/10/2021 at 21:00 point

I'll be watching this project with interest: I have one of these boards, and it looks really interesting, but some of the documentation left me scratching my head (for example, how to select one of the alternative user programmable ROM images in flash on bootup) and I haven't had time to experiment and figure it out myself!

  Are you sure? yes | no

Keith wrote 03/11/2021 at 03:46 point

I took the ROM out and read it with my device programmer. 
There's a guy who wrote some code to modify the Flash ROM in situ:
https://wdc65xx.com/w65c816sxb-hacker/

The bank is software selected, CA2 and CB2 of the TIDE VIA. You could mod the board to hardware-select the bank. 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates