This repo documents the evolution of a simple Z80 monitor for single board computer like Z80-MBC2.
This little computer already uses the Z80 version of WozMon, the tiny Apple ][ ROM monitor. Due to the reduced commands I decided to start a new monitor with extended command set.
80s-like this monitor is written in assembler with the SLR z80asm.com format. Development
happens on my Linux machine using zxcc or alternatively
tnylpo as CP/M emulator. During development the monitor
is an CP/M program to simplify the testing - it can easily switched to a standalone program
in ROM. The only two HW-related functions are
- conin (wait for char and return it in register A)
- conout (output char in register A)
The typical use case for Z80 SBCs is the combination with a terminal program running on the PC that connects to the serial port of the SBC. So the simplest way of program storage is to copy it from or to the terminal screen and store it on the PC. Therefore I decided to support the WozMon format for simple data storage.
The monitor program offers these functions with the following syntax:
<CMD><ADDRESS>[ <ARG> <ARG> ...]<RETURN>
-
VIEW memory content
VAAAA- View 16 bytes atAAAAas hex and ASCII (AAAA DD DD ... CC ..).V(or CR alone) - View the next 16 bytes after previous dump.WAAAA- Dump 16 bytes atAAAAin WozMon fmt (AAAA: DD DD ...).W(or CR alone) - Dump the next 16 bytes after previous dump in WozMon fmt.
-
MODIFY memory content
MAAAA DD DD ...- Modify mem atAAAA, no space between'M'and the address!.M DD DD ...- Modify next mem bytes.AAAA: DD DD ...- Modify mem atAAAAusing WozMon fmt (see SHOW).
-
GOTO program location
GAAAA- Goto program atAAAA.G- Goto program counter of user context, e.g. resume from last breakpoint.G0- Exit to CP/M or restart the Z80-MBC2 monitor.
-
BREAKPOINT set or clear
K- clear breaKpoint.K0- clear breaKpoint.KAAAA- set breaKpoint atAAAA.KAAAA BBBB- set breaKpoint atAAAAand reactivate it atBBBB. Breakpoints and reactivation points are implemented by replacing the opcode atAAAAandBBBBwithRSTinstructions.
This only works if the addressesAAAAandBBBBpoint to the first byte of the opcode (M1).
-
REGISTER display
R- show the user register including the 2nd register setAF',BC',DE',HL'and, if applicable, the address of the breakpoint and its recovery.
A F BC DE HL A' F' BC' DE' HL' IX IY I R PC SP
DE 8B 0600 0003 C504 55 00 0000 0000 0000 0000 0000 00 1B 100C 0740
Sz...p.C sz...p.c BrkPt: 100C/100D
- SET REGISTER prepare user context for the following
GcommandA dd- set registerAB dd- set registerBC dd- set registerCD dd- set registerDE dd- set registerEH dd- set registerHL dd- set registerLF dd- set flagsI dd- set interrupt vector registerP dddd- set program counterS dddd- set stack pointerX dddd- set registerIXY dddd- set registerIY
The command line input uses BS or RUB to delete to the left. ^C returns to CP/M.