/* Name of program file */
const char* ProgramFile;
-
+/* exit simulator after MaxCycles Cycles */
+unsigned long MaxCycles = 0;
/*****************************************************************************/
/* Code */
" -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"
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 */
OptVersion (Arg, 0);
break;
+ case 'x':
+ OptQuitXIns (Arg, GetArg (&I, 2));
+ break;
+
default:
UnknownOption (Arg);
break;
while (1) {
ExecuteInsn ();
+ if (MaxCycles && (GetCycles () >= MaxCycles)) {
+ Error ("Maximum number of cycles reached.");
+ exit (EXIT_FAILURE);
+ }
}
/* Return an apropriate exit code */