Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

WDC 65C02 SXB Monitor

A machine-language monitor for the WDC W65C02SXB single-board computer. The stock ROM that ships with these boards comes with a software that will only work with WDC's TIDE, which I was not able to get to work on Windows 11. So instead this replaces the stock ROM with a proper ROM monitor. The board's USB port is connected to an FT245RL USB-parallel FIFO which the monitor uses for as the debug port.

As a reminder, this machine uses a straightfoward ~32 K RAM + I/O space + 32 K ROM memory map:

$0000-$7EFF: RAM
$7F00-$7FFF: I/O space (USB port on VIA2 at $7FE0-$7FFF)
$8000-$FFFF: ROM

This was adapted from smon6502, itself an adaptation of the SMON monitor originally published in the German magazine 64'er in 1984. I say adapted because this is not a straight port: differences in interrupt handling between the original 6502 and the 65C02 required rewriting the trace and breakpoint code. The orignal source was written in VASM and used fixed addressing and required the C64's KERNAL ROM.

This is a rewrite specifically for the W65C02SXB, but using the cc65 toolchain and relocatable asm so it's likely portable to other computers.

Features

  • Memory fill, copy, compare, and dump in hex and ASCII
  • Integrated disassembler with 65C02 extended instruction set support
  • Search memory by byte sequence, opcode arguments, and addresses references
  • Load Intel HEX files from the terminal into memory
  • Trace / single-step / breakpoint execution
  • Address relocation (convert + copy)
  • Immediate evaluation (hex to decimal, binary to hex, etc., integer arithmetic)
  • Indirect jump through vectors (G (addr))
  • A W65C02SXB simulator implemented with py65

Memory Usage

Segment Bytes Contents
STARTUP 77 One-time init code
CODE 5315 Program code
RODATA 2274 Strings, tables, help text
DATA 37 Initialized data (copied from ROM at startup)
7703 ROM total (24% of 32 KB)
ZEROPAGE 73 Zero-page variables
BSS 2144 Uninitialized variables
2217 RAM total

Building

  • cc65 toolchain (ca65, ld65, cl65, ar65)
  • minipro (for flashing the ROM chip)
  • GNU Make
Target Description
make Build the 32 KB ROM image (build/rom.bin)
make pad Pad to 128 KB for the SST39SF010A (build/rom.pad)
make flash_rom Pad and flash via minipro
make test Run unit tests in a simulated 65C02 system
make sim Run the monitor interactively in the simulator
make clean Remove build artifacts
make rebuild Clean and rebuild

Note: the source uses the c_sp zero-page name, which requires a cc65 built from git master (the 2.19 release still calls it sp). The Makefile auto-detects the cc65 data directory in /usr/local/share/cc65 and /usr/share/cc65; override with make CC65_DATA_DIR=... if yours lives elsewhere.

The SBC uses a 128 KB ROM chip, but only the top 32 KB is visible to the CPU. The ROM image is padded with $FF to 128 KB for flashing.

You'll probably need a PLCC-32 to DIP-32 and a PLCC puller to flash the ROM chip, as well as a programmer. I was never able to get the board's built-in USB to work, which is why I'm using this in the first place.

Testing

make test runs the ROM image under a simulated W65C02SXB and drives the monitor through an emulated terminal, checking the responses. The simulation uses py65's 65C02 core with the board's memory map, and emulates the FT245 USB FIFO.

Requirements: python3 and py65 (pip install -r test/requirements.txt).

Monitor Commands

The monitor will start on NMI or BRK.

Type H at the monitor prompt to display the built-in help.

Command Syntax Description
A A xxxx Interactively assemble starting at xxxx (end with f, use Mxx for labels)
C C xxxx yyyy zzzz aaaa bbbb Convert: relocate addresses in xxxx-yyyy by offset zzzz, then copy to aaaa-bbbb
D D xxxx (yyyy) Disassemble from xxxx (to yyyy)
F F aa bb .., xxxx yyyy Find byte sequence aa bb .. in xxxx-yyyy
FA FA aaaa, xxxx yyyy Find absolute address aaaa in opcodes within xxxx-yyyy
FR FR aaaa, xxxx yyyy Find relative branch target aaaa in opcodes within xxxx-yyyy
FT FT xxxx yyyy Find table (non-opcode bytes) in xxxx-yyyy
FZ FZ aa, xxxx yyyy Find zero-page address aa in opcodes within xxxx-yyyy
FI FI aa, xxxx yyyy Find immediate argument aa in opcodes within xxxx-yyyy
G G (xxxx) Go - run from xxxx (or current PC); G (xxxx) jumps indirect through vector at xxxx
K K xxxx (yyyy) ASCII (ass-key) dump from xxxx (to yyyy)
L L Load Intel HEX data from terminal
M M xxxx (yyyy) Hex dump memory from xxxx (to yyyy)
MS MS Print memory size
MT MT xxxx yyyy (nn) Memory test xxxx-yyyy, repeat nn times
O O xxxx yyyy aa Fill (output) memory xxxx-yyyy with byte aa
P P xxxx Peek - read and display byte at xxxx
R R Display registers
S S xxxx aa Store - write byte aa to address xxxx
TW TW (xxxx) Trace walk - single-step from xxxx (no address: step once from current PC, then keep walking)
TB TB xxxx nn Trace break - set breakpoint at xxxx, stop after nn hits
TQ TQ (xxxx) Trace quick - run from xxxx (or current PC) to the breakpoint remembered from the last TS/TB
TS TS xxxx Trace stop - run until PC reaches xxxx
V V xxxx yyyy zzzz aaaa bbbb Relocate (move) address references in aaaa-bbbb from xxxx-yyyy to zzzz
W W xxxx yyyy zzzz Copy (write) memory xxxx-yyyy to zzzz
X X Exit monitor and return to interrupted code
? ? xxxx+yyyy Evaluate xxxx op yyyy (+ - * /), print result in hex, decimal, and binary
= = xxxx yyyy Compare memory at xxxx to memory at yyyy
# #ddd Convert decimal ddd to hex and binary
$ $xx Convert hex xx to decimal and binary
% %bbbbbbbb Convert binary bbbbbbbb to decimal and hex

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages