|Re: [hatari-devel] Getting cycles used by previous or next instruction without modifying CPU state?|
[ Thread Index |
| More lists.tuxfamily.org/hatari-devel Archives
On tiistai 21 helmikuu 2012, Nicolas Pomarède wrote:
> On 20/02/2012 23:50, Eero Tamminen wrote:
> > How do I get how many cycles previous instruction used, for
> > profiling purposes?
> > src/debug/profile.c has this code:
> > Uint32 opcode, cycles;
> > opcode = get_iword_prefetch (0);
> > cycles = (*cpufunctbl[opcode])(opcode) + nWaitStateCycles;
> > But that's bad, calling the opcode table function modifies
> > the CPU state.
> I don't think you can get this easily. Only the current instruction
> cycles are available.
> If that's just for test purpose, you can add some kind of breakpoint
> that would trigger on every instruction and then save the current cycles
> in your own variable. But this would certainly slow down emulation a lot.
This is for the profiler. If it cannot get the cycles either for previous
or next instruction without modifying/invalidating CPU state, it's better
if I remove that part.