From 3ec3e3aa8f8897e43dafcdf4e46621c5ce0145aa Mon Sep 17 00:00:00 2001 From: Patrick Linstruth Date: Sun, 27 Nov 2022 06:28:03 -0800 Subject: [PATCH] AltairZ80: Fix HALT stop code conflict with ON ERROR AltairZ80 uses 0 for the VM-specific HLT instruction stop code. SCP defines SCPE_OK as 0. SCP uses 0 to mean all errors ("ON ERROR"). The command "ON 0" will generate "%SIM-ERROR: Invalid argument: 0". This PR changes the HALT stop code from 0 to 5. --- AltairZ80/altairz80_defs.h | 2 +- AltairZ80/altairz80_sys.c | 5 +++-- scp.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/AltairZ80/altairz80_defs.h b/AltairZ80/altairz80_defs.h index a1185f26..b8fb36a1 100644 --- a/AltairZ80/altairz80_defs.h +++ b/AltairZ80/altairz80_defs.h @@ -64,11 +64,11 @@ typedef enum { } ChipType; /* simulator stop codes */ -#define STOP_HALT 0 /* HALT */ #define STOP_IBKPT 1 /* breakpoint (program counter) */ #define STOP_MEM 2 /* breakpoint (memory access) */ #define STOP_INSTR 3 /* breakpoint (instruction access) */ #define STOP_OPCODE 4 /* invalid operation encountered (8080, Z80, 8086) */ +#define STOP_HALT 5 /* HALT */ #define UNIT_CPU_V_OPSTOP (UNIT_V_UF+0) /* stop on invalid operation */ #define UNIT_CPU_OPSTOP (1 << UNIT_CPU_V_OPSTOP) diff --git a/AltairZ80/altairz80_sys.c b/AltairZ80/altairz80_sys.c index d9f86d06..5b834732 100644 --- a/AltairZ80/altairz80_sys.c +++ b/AltairZ80/altairz80_sys.c @@ -160,11 +160,12 @@ DEVICE *sim_devices[] = { static char memoryAccessMessage[256]; static char instructionMessage[256]; const char *sim_stop_messages[SCPE_BASE] = { - "HALT instruction", + "Unknown error", /* 0 is reserved/unknown */ "Breakpoint", memoryAccessMessage, instructionMessage, - "Invalid Opcode" + "Invalid Opcode", + "HALT instruction" }; static const char *const Mnemonics8080[] = { diff --git a/scp.c b/scp.c index dd97ecc0..f354c509 100644 --- a/scp.c +++ b/scp.c @@ -9445,7 +9445,7 @@ t_value pcval; fputc ('\n', st); /* start on a new line */ -if (v >= SCPE_BASE) /* SCP error? */ +if (v == SCPE_OK || v >= SCPE_BASE) /* SCP error? */ fputs (sim_error_text (v), st); /* print it from the SCP list */ else { /* VM error */ if (sim_stop_messages [v])