mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Merge pull request #320 from groessler/something_to_pull
sim65: add command line parameter to print number of CPU cycles at exit
This commit is contained in:
commit
48448e6bbb
@ -4,7 +4,7 @@
|
||||
|
||||
<title>sim65 Users Guide
|
||||
<author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
|
||||
<date>2016-01-05
|
||||
<date>2016-07-05
|
||||
|
||||
<abstract>
|
||||
sim65 is a simulator for 6502 and 65C02 CPUs. It allows to test target
|
||||
@ -31,12 +31,14 @@ The simulator is called as follows:
|
||||
Usage: sim65 [options] file [arguments]
|
||||
Short options:
|
||||
-h Help (this text)
|
||||
-c Print amount of executed CPU cycles
|
||||
-v Increase verbosity
|
||||
-V Print the simulator version number
|
||||
-x <num> Exit simulator after <num> cycles
|
||||
|
||||
Long options:
|
||||
--help Help (this text)
|
||||
--cycles Print amount of executed CPU cycles
|
||||
--verbose Increase verbosity
|
||||
--version Print the simulator version number
|
||||
</verb></tscreen>
|
||||
@ -53,6 +55,13 @@ Here is a description of all the command line options:
|
||||
Print the short option summary shown above.
|
||||
|
||||
|
||||
<tag><tt>-c, --cycles</tt></tag>
|
||||
|
||||
Print the number of executed CPU cycles when the program terminates.
|
||||
The cycles for the final "<tt>jmp exit</tt>" are not included in this
|
||||
count.
|
||||
|
||||
|
||||
<tag><tt>-v, --verbose</tt></tag>
|
||||
|
||||
Increase the simulator verbosity.
|
||||
|
@ -67,6 +67,8 @@ static unsigned HaveNMIRequest;
|
||||
/* IRQ request active */
|
||||
static unsigned HaveIRQRequest;
|
||||
|
||||
/* flag to print cycles at program termination */
|
||||
int PrintCycles;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -99,6 +99,8 @@ unsigned ExecuteInsn (void);
|
||||
unsigned long GetCycles (void);
|
||||
/* Return the total number of clock cycles executed */
|
||||
|
||||
extern int PrintCycles;
|
||||
/* flag to print cycles at program termination */
|
||||
|
||||
|
||||
/* End of 6502.h */
|
||||
|
@ -61,7 +61,7 @@
|
||||
const char* ProgramFile;
|
||||
|
||||
/* exit simulator after MaxCycles Cycles */
|
||||
unsigned long MaxCycles = 0;
|
||||
unsigned long MaxCycles;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
@ -74,12 +74,14 @@ static void Usage (void)
|
||||
printf ("Usage: %s [options] file [arguments]\n"
|
||||
"Short options:\n"
|
||||
" -h\t\t\tHelp (this text)\n"
|
||||
" -c\t\t\tPrint amount of executed CPU cycles\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"
|
||||
" --cycles\t\tPrint amount of executed CPU cycles\n"
|
||||
" --verbose\t\tIncrease verbosity\n"
|
||||
" --version\t\tPrint the simulator version number\n",
|
||||
ProgName);
|
||||
@ -106,6 +108,15 @@ static void OptVerbose (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
|
||||
static void OptCycles (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Set flag to print amount of cycles at the end */
|
||||
{
|
||||
PrintCycles = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OptVersion (const char* Opt attribute ((unused)),
|
||||
const char* Arg attribute ((unused)))
|
||||
/* Print the simulator version */
|
||||
@ -166,6 +177,7 @@ int main (int argc, char* argv[])
|
||||
/* Program long options */
|
||||
static const LongOpt OptTab[] = {
|
||||
{ "--help", 0, OptHelp },
|
||||
{ "--cycles", 0, OptCycles },
|
||||
{ "--verbose", 0, OptVerbose },
|
||||
{ "--version", 0, OptVersion },
|
||||
};
|
||||
@ -196,6 +208,10 @@ int main (int argc, char* argv[])
|
||||
OptHelp (Arg, 0);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
OptCycles (Arg, 0);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
OptVerbose (Arg, 0);
|
||||
break;
|
||||
|
@ -156,6 +156,9 @@ static void PVArgs (CPURegs* Regs)
|
||||
static void PVExit (CPURegs* Regs)
|
||||
{
|
||||
Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC);
|
||||
if (PrintCycles) {
|
||||
Print (stdout, 0, "%lu cycles\n", GetCycles ());
|
||||
}
|
||||
|
||||
exit (Regs->AC);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user