Since there doesn't seem to be an emulator for the 65816 that is easy to use with Linux, I've decided to embrace my delusions of grandeur and write my own. Now this all but makes sure it will be horribly crude, so I've named it "A Crude 65816 Emulator" (crude65816). The PRE-ALPHA version is now on GitHub at
https://github.com/scotws/crude65816 .
"Pre-Alpha" means that some stuff gets set up and the main loop will run (or single-step). To save everybody the trouble of downloading, this is pretty much the whole extent of the output at the moment:
Code:
A Crude 65816 Emulator in Forth
Version pre-ALPHA 26. May 2015
Copyright 2015 Scot W. Stevenson <scot.stevenson@gmail.com>
This program comes with ABSOLUTELY NO WARRANTY
Defining general stuff ...
Setting up CPU ...
Creating memory ...
Loading ROM files to memory ...
Setting up flag routines ...
Defining opcode routines ...
Generating opcode jump table ...
Setting up interrupts ...
All done.
PC K BA X Y S D B NV-BDIZC
E0C5 00 0000 0000 0000 0100 0000 00 00000000 emulated
Machine ready. Type 'run' to start emulation, 'step' for single-step. Type `bye' to exit
go-native ok
.state
PC K C X Y S D B NVMXDIZC
E0C5 00 0000 0000 0000 0100 0000 00 00110000 native
ok
run A9 not coded yet85 not coded yetA9 not coded yet85 not coded yet20 not coded yetB6 not coded yetE0 not coded yetA9 not coded yet8D not coded yet00 not coded yet
Hit BRK command (ALPHA testing only)
"go-native" switches the processor to native (16-bit) mode, which reflects in the ".state" command (for non-Forthwrights: Forth commands with a dot by convention print information). All the stuff about "not yet coded" is because the mini-monitor program I'm using -- all still 8-bit code for the 6502 -- just hits a bunch of placeholder routines. The BRK command simply triggers Forth QUIT for the moment.
The memory model is crude as well. The emulator simply reserves 16 MByte of RAM as the whole address space of the 65816 (which is why gforth must be called with "-m 1G" option). There is a configuration file that lets you load ROM into the address space, and define "putchar" and "getchar" (don't work yet). There is no write protection for these ROM areas. The crude65816 will attempt to handle the mode switches with DEFER statements. The devil will obviously be in the details, and I haven't even started to code the addressing modes.
So now I have a chicken-and-egg problem, because to really test the emulator, I'll need a 65816 assembler, and to test the assembler, I'll need an emulator. At some point, I'll be adapting my tasm65c02 assembler (
https://github.com/scotws/tasm65c02) to a 65816 version.
Any feedback, corrections or suggestions are of course most very welcome!