Re: [hatari-devel] Getting cycles used by previous or next instruction without modifying CPU state?

[ Thread Index | Date Index | More Archives ]

On 22/02/2012 20:39, Eero Tamminen wrote:

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.

 From where?

Well, it's almost everywhere in the traces I added in various parts :) -> CurrentInstrCycles

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.

Then I guess it won't be possible. Calling opcode() will really run the instruction (and change cpu/memory), and some instructions have variable number of cycles depending on their parameters (lsl, rol, mul, div, ...)


Mail converted by MHonArc 2.6.19+