mirror of
https://github.com/cc65/cc65.git
synced 2025-01-26 17:36:57 +00:00
added commandline option to quit after X cycles
This commit is contained in:
parent
9b82eaadd0
commit
adc5525e85
@ -60,7 +60,8 @@
|
|||||||
/* Name of program file */
|
/* Name of program file */
|
||||||
const char* ProgramFile;
|
const char* ProgramFile;
|
||||||
|
|
||||||
|
/* exit simulator after MaxCycles Cycles */
|
||||||
|
unsigned long MaxCycles = 0;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
@ -75,6 +76,7 @@ static void Usage (void)
|
|||||||
" -h\t\t\tHelp (this text)\n"
|
" -h\t\t\tHelp (this text)\n"
|
||||||
" -v\t\t\tIncrease verbosity\n"
|
" -v\t\t\tIncrease verbosity\n"
|
||||||
" -V\t\t\tPrint the simulator version number\n"
|
" -V\t\t\tPrint the simulator version number\n"
|
||||||
|
" -x <num>\t\tExit simulator after <num> cycles\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Long options:\n"
|
"Long options:\n"
|
||||||
" --help\t\tHelp (this text)\n"
|
" --help\t\tHelp (this text)\n"
|
||||||
@ -111,7 +113,12 @@ static void OptVersion (const char* Opt attribute ((unused)),
|
|||||||
fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
|
fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OptQuitXIns (const char* Opt attribute ((unused)),
|
||||||
|
const char* Arg attribute ((unused)))
|
||||||
|
/* quit after MaxCycles cycles */
|
||||||
|
{
|
||||||
|
MaxCycles = strtoul(Arg, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void ReadProgramFile (void)
|
static void ReadProgramFile (void)
|
||||||
/* Load program into memory */
|
/* Load program into memory */
|
||||||
@ -197,6 +204,10 @@ int main (int argc, char* argv[])
|
|||||||
OptVersion (Arg, 0);
|
OptVersion (Arg, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
OptQuitXIns (Arg, GetArg (&I, 2));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
UnknownOption (Arg);
|
UnknownOption (Arg);
|
||||||
break;
|
break;
|
||||||
@ -225,6 +236,10 @@ int main (int argc, char* argv[])
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ExecuteInsn ();
|
ExecuteInsn ();
|
||||||
|
if (MaxCycles && (GetCycles () >= MaxCycles)) {
|
||||||
|
Error ("Maximum number of cycles reached.");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return an apropriate exit code */
|
/* Return an apropriate exit code */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user