1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-25 13:29:41 +00:00

added commandline option to quit after X cycles

This commit is contained in:
mrdudz 2014-09-25 18:47:23 +02:00
parent 9b82eaadd0
commit adc5525e85

View File

@ -60,7 +60,8 @@
/* Name of program file */
const char* ProgramFile;
/* exit simulator after MaxCycles Cycles */
unsigned long MaxCycles = 0;
/*****************************************************************************/
/* Code */
@ -75,6 +76,7 @@ static void Usage (void)
" -h\t\t\tHelp (this text)\n"
" -v\t\t\tIncrease verbosity\n"
" -V\t\t\tPrint the simulator version number\n"
" -x <num>\t\tExit simulator after <num> cycles\n"
"\n"
"Long options:\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 ());
}
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)
/* Load program into memory */
@ -197,6 +204,10 @@ int main (int argc, char* argv[])
OptVersion (Arg, 0);
break;
case 'x':
OptQuitXIns (Arg, GetArg (&I, 2));
break;
default:
UnknownOption (Arg);
break;
@ -225,6 +236,10 @@ int main (int argc, char* argv[])
while (1) {
ExecuteInsn ();
if (MaxCycles && (GetCycles () >= MaxCycles)) {
Error ("Maximum number of cycles reached.");
exit (EXIT_FAILURE);
}
}
/* Return an apropriate exit code */