Machine-code monitor, fast serial, memory files, Ctrl-Alt-Del
Monitor: the CPU gets an NMI (taken at an instruction start, or from HALT) raised by the Pause key, BASIC's MONITOR, two hardware breakpoint comparators or a step counter. It enters through a trampoline at 0066h (the same bytes in BASIC's ROM and the monitor's, basic/tramp.s) that switches in a 32 KB monitor bank over 0000-7FFF. The monitor (monitor/, C) runs on the terminal's new alternate screen (CSI ?47 h/l, a second screen page; graphics hidden) and shows registers, flags, a disassembly from PC, the stack and memory. Commands: Enter/S n step, O step over, G/X go, B breakpoint, D/M windows, E edit, R registers, and SAVE/LOAD/ DIR for memory files. The disassembler covers every opcode; monitor/test-disasm.py round-trips all forms through sdasz80. Lockstep CPU tests still match the reference emulator. BASIC: MONITOR, CALL addr, BSAVE "N",start,len and BLOAD "N"[,addr] (memory files: load address then bytes). The DATE clock moves to F3F8h so the monitor can date files. F000-F3F7 is kept free for machine code (program area 21076 bytes). Serial: SW1:0 = 10 is now 921600 and 11 is 3 Mbaud. A 17 KB burst to BASIC lists back identical at both on the board. send-bas.py reads the echo while sending; unread, it could stall the PC's flow control. Ctrl-Alt-Del in Z-80 mode restarts the Z-80 like BTND. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
767377f38d
commit
634e314010
27 files changed
+37481
-3039
No files matched your search
+46
-4
@@ -205,7 +205,7 @@ enum {
|
||||
T_TO, T_STEP, T_NEXT, T_DIM, T_DEF, T_END, T_STOP, T_REM, T_READ, T_DATA,
|
||||
T_RESTORE, T_ON, T_RANDOMIZE, T_POKE, T_OUT, T_RUN, T_LIST, T_NEW, T_SCRATCH,
|
||||
T_BYE, T_CLS, T_COLOR, T_PLOT, T_LINE, T_RECT, T_FILL, T_CIRCLE, T_LOCATE, T_INK,
|
||||
T_SAVE, T_LOAD, T_DIR, T_DEL, T_DATE, T_OPEN, T_CLOSE, T_OUTPUT, T_APPEND, T_AND, T_OR, T_NOT, T_SIN, T_COS, T_TAN, T_ATN, T_EXP, T_LOG, T_ABS,
|
||||
T_SAVE, T_LOAD, T_DIR, T_DEL, T_DATE, T_OPEN, T_CLOSE, T_MONITOR, T_CALL, T_BSAVE, T_BLOAD, T_OUTPUT, T_APPEND, T_AND, T_OR, T_NOT, T_SIN, T_COS, T_TAN, T_ATN, T_EXP, T_LOG, T_ABS,
|
||||
T_SQR, T_INT, T_RND, T_SGN, T_FN, T_TAB, T_PEEK, T_INP, T_LEN, T_VAL, T_ASC, T_EOF,
|
||||
T_CHRS, T_STRS, T_LEFTS, T_RIGHTS, T_MIDS, T_DATES, T_TIM, T_POINT, T_LE, T_GE, T_NE, T_LAST
|
||||
};
|
||||
@@ -215,13 +215,14 @@ static const char *const kw[] = {
|
||||
"TO", "STEP", "NEXT", "DIM", "DEF", "END", "STOP", "REM", "READ", "DATA",
|
||||
"RESTORE", "ON", "RANDOMIZE", "POKE", "OUT", "RUN", "LIST", "NEW", "SCRATCH",
|
||||
"BYE", "CLS", "COLOR", "PLOT", "LINE", "RECT", "FILL", "CIRCLE", "LOCATE", "INK",
|
||||
"SAVE", "LOAD", "DIR", "DEL", "DATE", "OPEN", "CLOSE", "OUTPUT", "APPEND", "AND", "OR", "NOT", "SIN", "COS", "TAN", "ATN", "EXP", "LOG", "ABS",
|
||||
"SAVE", "LOAD", "DIR", "DEL", "DATE", "OPEN", "CLOSE", "MONITOR", "CALL", "BSAVE", "BLOAD", "OUTPUT", "APPEND", "AND", "OR", "NOT", "SIN", "COS", "TAN", "ATN", "EXP", "LOG", "ABS",
|
||||
"SQR", "INT", "RND", "SGN", "FN", "TAB", "PEEK", "INP", "LEN", "VAL", "ASC", "EOF",
|
||||
"CHR$", "STR$", "LEFT$", "RIGHT$", "MID$", "DATE$", "TIM", "POINT", "<=", ">=", "<>"
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------- memory */
|
||||
#define ARENA 22100 /* program text grows up, arrays grow down */
|
||||
#define ARENA 21076 /* program text grows up, arrays grow down;
|
||||
F000-F3F7 is left free for machine code */
|
||||
#define STRMAX 80
|
||||
#define NVARS (26 * 11)
|
||||
#define FORMAX 16
|
||||
@@ -322,8 +323,15 @@ static void error(u8 e)
|
||||
/* The date and time, set by DATE (the PC tools set it when they connect) and
|
||||
kept from the millisecond counter until the power goes off. Held as seconds
|
||||
since 2000-01-01 00:00; 0 means not set. */
|
||||
#ifdef __SDCC
|
||||
/* at a fixed address (between BASIC's data and the stack) so the monitor
|
||||
can read the clock too */
|
||||
static volatile __at(0xF3F8) u32 clk_sec;
|
||||
static volatile __at(0xF3FC) i32 clk_ms; /* millis() at clk_sec */
|
||||
#else
|
||||
static u32 clk_sec;
|
||||
static i32 clk_ms; /* millis() at clk_sec */
|
||||
static i32 clk_ms;
|
||||
#endif
|
||||
|
||||
static u32 now(void)
|
||||
{
|
||||
@@ -1895,6 +1903,32 @@ static void st_close(void)
|
||||
} while (accept(','));
|
||||
}
|
||||
|
||||
/* BSAVE "NAME", start, length / BLOAD "NAME" [, address]: memory files,
|
||||
the load address (2 bytes) and then the bytes, as the monitor writes them */
|
||||
static void st_bfile(u8 t)
|
||||
{
|
||||
char nm[8];
|
||||
u16 a, n;
|
||||
int b;
|
||||
struct chan *c = &ch[0];
|
||||
c->mode = 0;
|
||||
get_name(nm);
|
||||
if (t == T_BSAVE) {
|
||||
expect(','); a = (u16)(i32)expr();
|
||||
expect(','); n = (u16)(i32)expr();
|
||||
chan_open_out(c, nm, 0);
|
||||
chan_putc(c, a); chan_putc(c, a >> 8);
|
||||
while (n--) chan_putc(c, peek(a++));
|
||||
chan_close(c);
|
||||
} else {
|
||||
chan_open_in(c, nm);
|
||||
a = chan_getc(c); a |= chan_getc(c) << 8;
|
||||
if (accept(',')) a = (u16)(i32)expr();
|
||||
while ((b = chan_getc(c)) >= 0) poke(a++, b);
|
||||
c->mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void st_save(void)
|
||||
{
|
||||
char nm[8];
|
||||
@@ -2054,6 +2088,11 @@ static void statement(void)
|
||||
case T_DEL: st_del(); break;
|
||||
case T_OPEN: st_open(); break;
|
||||
case T_CLOSE: st_close(); break;
|
||||
case T_BSAVE: case T_BLOAD: st_bfile(t); break;
|
||||
#ifdef __SDCC
|
||||
case T_MONITOR: io_out(0x61, 0); break; /* NMI into the monitor */
|
||||
case T_CALL: ((void (*)(void))(u16)(i32)expr())(); break;
|
||||
#endif
|
||||
case T_DATE: {
|
||||
char d[STRMAX];
|
||||
if (is_str_start()) { sexpr(d); set_date(d); break; }
|
||||
@@ -2115,6 +2154,9 @@ int main(void)
|
||||
{
|
||||
u16 n;
|
||||
u8 *p;
|
||||
#ifdef __SDCC
|
||||
clk_sec = 0;
|
||||
#endif
|
||||
new_prog();
|
||||
g_clear(0);
|
||||
newline();
|
||||
|
||||
Reference in new issue
Block a user