This adds timer functionality to sim65.
It provides access to a handful of 64-bit counters that count different things: - clock cycles - instructions - number of IRQ processed - number of NMIs processed - nanoseconds since 1-1-1970. This in not ready yet to be pushed as a merge request into the upstream CC65 repository. What's lacking: - documentation - tests And to be discussed: - do we agree on this implementation direction and interface in principe? - can I include inttypes.h for printing a 64-bit unsigned value? - will clock_gettime() work on a Windows build?
This commit is contained in:
@@ -36,9 +36,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include "peripherals.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -50,9 +51,6 @@
|
||||
/* flag to print cycles at program termination */
|
||||
int PrintCycles = 0;
|
||||
|
||||
/* cycles are counted by main.c */
|
||||
extern unsigned long long TotalCycles;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -120,7 +118,7 @@ void SimExit (int Code)
|
||||
/* Exit the simulation with an exit code */
|
||||
{
|
||||
if (PrintCycles) {
|
||||
fprintf (stdout, "%llu cycles\n", TotalCycles);
|
||||
fprintf (stdout, PRIu64 " cycles\n", PRegs.counter_clock_cycles);
|
||||
}
|
||||
exit (Code);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user