Discussion of 65C816 support for the built-in MONitor utility.
These changes seem less important if we do not support native mode execution, but the community seems pretty intent on making native mode work, so we have some things to consider:
MON will need a new command to select 65C02, 65C816-emulation and 65C816-native mode, due to the additional register count, wider registers, and changed flag labels. These will be called: C02, 816e, and 816n.
MON needs a way to actively track .a and .x flags (Memory Width and Index Width) during disassembly. This will require a new command, as well, to set the expected state of those flags prior to disassembly.
The new 65C816 instructions will need to be added to the assembly/disassembly table
The new address modes will need to be added
The status line needs to be extended, with 2-byte words for the wider registers, the additional bank registers, and the new labels for the flags (which will vary depending on the emulation flag.) This includes extending the memory space used as a proxy for the register values.
When assembling and disassembling, MONITOR will need to track the expected state of the Accumulator Register Width (.a) and Index Register Width (.x) flags, in addition to the .e flag (which forces .a and .x to 8-bits when in 65C02 emulation mode.)
The toughest nut to crack might be the BRK issue. We can't simply BRK in native mode, which means we lose access to the 16-bit registers. If we add a ROM routine named "brk16", a dev can JSR brk16, which will
Set aside a block of memory as a native mode register proxy space, with room for all registers and an extra byte for the register display mode.
Push all registers to the stack. Push flags LAST. (because flags affect 8/16 bit mode and so change the number of bytes on the stack)
Set .a and .x to 8 bit operation
Set emulation mode
Pull data from the stack into the register proxy space.
Execute the BRK instruction
MON inspects the register display flag and displays the CPU state in one of 3 modes:
65C02 mode
65C816e (8 bit registers, "B" register, include banks and .e flag.)
65C816n (16 bit registers, include banks, and .a .i flags)
Discussion of 65C816 support for the built-in MONitor utility.
These changes seem less important if we do not support native mode execution, but the community seems pretty intent on making native mode work, so we have some things to consider:
The toughest nut to crack might be the BRK issue. We can't simply BRK in native mode, which means we lose access to the 16-bit registers. If we add a ROM routine named "brk16", a dev can JSR brk16, which will