Re: [hatari-devel] Code execution discontinuities and detecting them? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Le 25/02/2013 17:43, Eero Tamminen a écrit :
Is JMP used for subroutines in C-compiler (e.g. gcc) generated code or
just in hand-coded assembly?
And in how many cases approximately, 1%? 50%?
it could be ; if the last code of a subroutine is a call to another
subroutine :
sub1:
...
jsr sub2
rts
sub2:
...
rts
then it's more efficient (in term of size of the program and cpu cycles)
to write :
sub1:
....
jmp sub2
sub2:
...
rts
Any clever compiler could do this.
What about other m68k CPU models?
I don't know for sure, but I guess 10 is the max for 68000. On higher
cpu, FPU operation could use more bytes maybe.
What about BKPT, CHK, ILLEGAL instructions? Aren't those used at all?
BKPT and CHK are very rare in common programs.
ILLEGAL is often used in debuger to create breakpoints, so that's kinda
rare too.
So maybe having a list of "instructions that can modify the PC" in your
python script is enough to determine the call flow :
That checking will be done in Hatari profiler code, as that check needs to
be done for every symbol address "call" and have information about current
CPU state, not just averages over whole profiling run (like the post-
processing script has).
Also, post-processor doesn't know anything about the processor itself,
I'm going to use just flags for the callers, those will be the same
for both CPU and DSP caller information.
By having the opcode type of the current instruction (as text or as an
integer (as it already exists in the cpu part)), you can determine to
which opcode family this opcode is related.
- if previous instr is in this list, then you have a potential
subroutine call (but it could be a if/then/else block too)
- if current pc differs from ( previous pc + number of bytes for
previous instruction ) AND previous instr is not in the above list, then
it's quite likely you had an exception.
Hatari profiler code has also access to CPU state variables,
like state register value.
Can those be used to (more) reliably detect interrupt handlers or
exceptions?
The SR is not enough ; you can have an exception inside an exception,
and in that case the SR will already be in supervisor mode.
I don't think there's anything in the cpu state that tell if an
exception just hapenned.
Nicolas