W65C816S CPU support in Emu
- smokku
The preliminary version of Emu used an M6502 chip emulator. I’ve spent the past week+ working on extending it into a full-fledged W65C816S CPU emulator chip.
Once again, choosing chip-emulators as the base for Emu has proven to be a perfect choice.
The original chip
CPU emulators are built from two parts:
- A C shell providing a
chip emulator
wrapper
- A Python script for an instruction decoder generator
The C header file provides integration with the rest of the system via chip pin emulation. The Python script works with a matrix of instruction operands and addressing modes - just like a real hardware CPU instruction decoder.
It was meticulous work for a real bean-counter, mapping the W65C816S datasheet to my freshly-forked w65c816s_gen.py
, but I bet it was way easier than writing such an emulator from scratch. Especially with no prior experience.
In the process, I created a headless CPU simulator, inspired by a CODE GOLF post.
This tool allows me to run automated tests for the CPU implementation:

In interactive mode, it’s even capable of running EhBASIC:

Things are looking good…