Re: [hatari-devel] Feature request/idea: cycle counting

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Le 31/01/2018 à 23:51, Miro Kropáček a écrit :
On 1 February 2018 at 09:46, Nicolas Pomarède <npomarede@xxxxxxxxxxxx <mailto:npomarede@xxxxxxxxxxxx>> wrote:

cpu video_cyc= 40780 332@ 79 : 00014566 224c  MOVEA.L A4,A1 cpu video_cyc= 40784 336@ 79 : 00014568 d2dd  ADDA.W (A5)+ [1530],A1

    the value after video_cys is the global cycle position since the
    start of the current VBL. So here we can see that "MOVEA.L A4,A1"
    takes 40784-40780 cycles.
    This works well as long as all the instructions are in the same VBL.

    Is that the kind of values you're looking for ?

In a less cryptic way, yes. ;) So you see, it's already there! I could live with /trace cpu_disasm/ instead of having it in the disasm view, it just needs some polishing (to be honest, I had no idea what those numbers mean).

The problem is that for now the disasm traces don't "know" the number of cycles at the time the printf is made The emulation does this :

- print disasm log for current opcode (addr 14566 above)
- emulate current opcode (addr 14566)
- increase cycle counter with number of emulated cycles for 14566
- increase PC to next opcode

- print disasm log for current opcode (addr 14568 above)
- emulate current opcode (addr 14568)
- increase cycle counter with number of emulated cycles for 14568
- increase PC to next opcode

As you can see, when disasm log for 14566 is printed, number of cycles is not known yet. It's only when next instruction is logged that we have the new value for cpu_video_cyc (40784).

So, you need to substract 2 logs to know the number of cycles for 1 instructtion, which can look less obvious.

But on the contrary, when you want to know the number of cycles of 100 instructions, you just need to substract start and end cpu_video_cyc, instead of doing 100 individual additions yourself.

So, there's no real solution for all cases.
We could print a global cpu_vido_cyc as well as a per instruction number of cycles, but as explained above this is not feasible with the current code (and modifying code order in this time critical part of the emulation can have effect, even when traces are disabled)

Nicolas





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/