From 2cb457b85f8019e6437907ddd19e3d2c5f2546c6 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:51:12 -0400 Subject: [PATCH] sim65 use error codes outside the simulated program's range for non-sim errors --- doc/sim65.sgml | 7 +++++++ src/sim65/error.h | 8 +++++--- src/sim65/paravirt.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index c838cd3b0..b1e5afbdc 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -44,6 +44,13 @@ The simulator is called as follows: --version Print the simulator version number +sim65 will exit with the error code of the simulated program, +which is limited to an 8-bit result 0-255. + +An error in sim65, like bad arguments or an internal problem will exit with Command line options in detail

diff --git a/src/sim65/error.h b/src/sim65/error.h index a016881c6..6dbee974c 100644 --- a/src/sim65/error.h +++ b/src/sim65/error.h @@ -49,10 +49,12 @@ -#define SIM65_ERROR 0x7F -/* Does not use EXIT_FAILURE because it may overlap with test results. */ +#define SIM65_ERROR -1 +/* An error result for errors that are not part of the simulated test. +** Note that set simulated test can only return 8-bit errors 0-255. +*/ -#define SIM65_ERROR_TIMEOUT 0x7E +#define SIM65_ERROR_TIMEOUT -2 /* An error result for max CPU instructions exceeded. */ extern int PrintCycles; diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index af162acfa..2e52d6e7e 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -124,7 +124,7 @@ static unsigned PopParam (unsigned char Incr) static void PVExit (CPURegs* Regs) { Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC); - SimExit (Regs->AC); + SimExit (Regs->AC); /* Error code in range 0-255. */ }