sim64 universal 64-bit cycle count support:

MaxCycleCount is accounted by countdown, eliminating the 1-instruction-overhead issue, and removing the need to compare against a growing TotalCycles.
Makes main.c responsible for counting total cycles, instead of 6502.c, so the size of MaxCycleCount etc. is fully determined in one location.
Makes error.c responsible for PrintCycles instead of paravirt.c, so that it can be treated globally instead of
Return value of main() should be SIM65_ERROR because it is unreachable by design.
This commit is contained in:
bbbradsmith
2023-05-07 16:26:42 -04:00
parent 84f0ab322d
commit 0081fe548c
6 changed files with 53 additions and 48 deletions

View File

@@ -41,6 +41,20 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* flag to print cycles at program termination */
int PrintCycles = 0;
/* cycles are counted by main.c */
extern unsigned long long TotalCycles;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
@@ -99,3 +113,14 @@ void Internal (const char* Format, ...)
va_end (ap);
exit (SIM65_ERROR);
}
void SimExit (int Code)
/* Exit the simulation with an exit code */
{
if (PrintCycles) {
fprintf (stdout, "%llu cycles\n", TotalCycles);
}
exit (Code);
}