Add a mechanism to count how often the simulated CPU visits different program addresses by counting PC register values.
Requirements for a solution
It should only be active when INSTR_STAT macro is defined. I.e., it should be conditionally built in.
It should maintain an array of counters to keep statistics for individual PC values. After every instruction is simulated, the corresponding counter for its PC should be incremented by one.
At the end of simulation, the results table should be produced. It should look like this:
Address Count
0x0 1000
0x2 1000
0x6 1234
...
*It can be implemented in a generic manner to support all variants of interpreters
After the implementation is ready, it will be nice to compare performance of two builds - interpreter with stats enabled and disabled, to see the performance overhead such collection creates.
Add a mechanism to count how often the simulated CPU visits different program addresses by counting
PC
register values.Requirements for a solution
It should maintain an array of counters to keep statistics for individual PC values. After every instruction is simulated, the corresponding counter for its PC should be incremented by one. At the end of simulation, the results table should be produced. It should look like this:
Address Count
0x0 1000 0x2 1000 0x6 1234 ...
*It can be implemented in a generic manner to support all variants of interpreters
After the implementation is ready, it will be nice to compare performance of two builds - interpreter with stats enabled and disabled, to see the performance overhead such collection creates.