Re: [hatari-devel] Debugger: instruction at PC

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


Hi Eero,

sorry for my late reply, I has starred the email but didn't find time to verify some things until now..

And from what you concluded that "cpureg" shows already executed
instruction and not one that's going to be executed next?
OK, I did more tests now. You're right, the first disasm instruction and the instruction which is shown by 'cpureg' really show the next instruction to be processed. The confusing part was for me, as a person used to Atari debuggers for years, that PC in this case points to the next instruction after the instruction which is about to process, i.e. two instructions in advance.

PC is always for me 'this is the next instruction'. To be fair, the debugger says "next PC" but it's really confusing, at least for the little brain of mine.

Having said all of that, there is still something fishy going on. Look at this:

> r
[...]
0000d89e: 6602 4e68 43fa 0040 3018 BNE.B #$00000002 == 0000d8a2 (TRUE)

This, according to your/my observation should say that a jump is going to happen, right? Cool. It's true. But then explain why do I see this:

0000d89e: 6602 4e68 43fa 0040 3018 BNE.B #$00000002 == 0000d8a2 (TRUE)
next PC: 0000d8a0
> d
$00d8b4 : 0c50 0000                            cmpi.w    #0,(a0)
$00d8b8 : 6706                                 beq.s     $d8c0

Shouldn't be 'd' showing the jump instruction? Interestingly, it's not always reproducible. I'm attaching complete log from this session (the example above is near the end) to prove that I'm not making this up ;-)

If you were asking to show disassembly for next instruction when
when (re-)entering the debugger, does the attached patch what
you'd like to have?
I'm not sure, first I'd like to see the disasm output making sense for me ;-)

What "cpureg" shows should be correct, as it should be what
instruction CPU emulation core is going to emulate. :-)

Was "adda.l" the correct interpretation?
No it wasn't. 'addq' is the correct code, same as here:

00e15216: 5279 0000 5978 206e 0008 ADD.W #$00000001,$00005978
$e15216 : 5279 0000 5978                       addq.w    #1,$5978

--
MiKRO / Mystic Bytes
http://mikro.atari.org
> c
Returning to emulation...
1. CPU breakpoint condition(s) matched 1 times.
        GemdosOpcode = 0x4b

CPU=$e0123e, VBL=424, FrameCycles=70620, HBL=139, LineCycles=8, DSP=N/A
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 00e0095d A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd8 
USP=00000000 ISP=00003dd8 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0                                                                                  
N=0 Z=0 I=0 NAN=0                                                                                            
prefetch 004b4e41                                                                                            
00e0123e: 4e41 defc 0010 2040 217c TRAP.L #$00000001                                                         
next PC: 00e01240                                                                                            
> d                                                                                                          
$e0123e : 4e41                                 trap      #1                                                  
$e01240 : defc 0010                            adda.w    #$10,sp                                             
$e01244 : 2040                                 movea.l   d0,a0                                               
$e01246 : 217c 00e0 126a 0008                  move.l    #$e0126a,8(a0)                                      
$e0124e : 2f0b                                 move.l    a3,-(sp)
$e01250 : 2f00                                 move.l    d0,-(sp)
$e01252 : 2f0b                                 move.l    a3,-(sp)
$e01254 : 3f3c 0004                            move.w    #4,-(sp)
> s

CPU=$d88e, VBL=424, FrameCycles=70656, HBL=139, LineCycles=44, DSP=N/A
> d
$00d88e : 41fa 0052                            lea       $d8e2(pc),a0
$00d892 : 4a50                                 tst.w     (a0)
$00d894 : 663e                                 bne.s     $d8d4
$00d896 : 41ef 0006                            lea       6(sp),a0
$00d89a : 0817 0005                            btst      #5,(sp)
$00d89e : 6602                                 bne.s     $d8a2
$00d8a0 : 4e68                                 move      usp,a0
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 00e0095d A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch defc0010
0000d88e: 41fa 0052 4a50 663e 41ef LEA.L (PC,$0052) == $0000d8e2,A0
next PC: 0000d892
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 00e0095d A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch defc0010
0000d88e: 41fa 0052 4a50 663e 41ef LEA.L (PC,$0052) == $0000d8e2,A0
next PC: 0000d892
> s

CPU=$d892, VBL=424, FrameCycles=70664, HBL=139, LineCycles=52, DSP=N/A
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 0000d8e2 A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch 00524a50
0000d892: 4a50 663e 41ef 0006 0817 TST.W (A0)
next PC: 0000d894
> d
$00d892 : 4a50                                 tst.w     (a0)
$00d894 : 663e                                 bne.s     $d8d4
$00d896 : 41ef 0006                            lea       6(sp),a0
$00d89a : 0817 0005                            btst      #5,(sp)
$00d89e : 6602                                 bne.s     $d8a2
$00d8a0 : 4e68                                 move      usp,a0
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
$00d8a6 : 3018                                 move.w    (a0)+,d0
> s

CPU=$d894, VBL=424, FrameCycles=70672, HBL=139, LineCycles=60, DSP=N/A
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 0000d8e2 A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=1 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch 663e41ef
0000d894: 663e 41ef 0006 0817 0005 BNE.B #$0000003e == 0000d8d4 (FALSE)
next PC: 0000d896
> lock disasm 
Locked disasm output.
> s
$00d896 : 41ef 0006                            lea       6(sp),a0
$00d89a : 0817 0005                            btst      #5,(sp)
$00d89e : 6602                                 bne.s     $d8a2
$00d8a0 : 4e68                                 move      usp,a0
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
$00d8a6 : 3018                                 move.w    (a0)+,d0
$00d8a8 : 0c40 0100                            cmpi.w    #$100,d0
$00d8ac : 6426                                 bcc.s     $d8d4
> s
$00d89a : 0817 0005                            btst      #5,(sp)
$00d89e : 6602                                 bne.s     $d8a2
$00d8a0 : 4e68                                 move      usp,a0
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
$00d8a6 : 3018                                 move.w    (a0)+,d0
$00d8a8 : 0c40 0100                            cmpi.w    #$100,d0
$00d8ac : 6426                                 bcc.s     $d8d4
$00d8ae : 0c40 004b                            cmpi.w    #$4b,d0
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 00003dd8 A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=1 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch 00060817
0000d89a: 0817 0005 6602 4e68 43fa BTST.B #$0005,(A7)
next PC: 0000d89e
> s
$00d89e : 6602                                 bne.s     $d8a2
$00d8a0 : 4e68                                 move      usp,a0
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
$00d8a6 : 3018                                 move.w    (a0)+,d0
$00d8a8 : 0c40 0100                            cmpi.w    #$100,d0
$00d8ac : 6426                                 bcc.s     $d8d4
$00d8ae : 0c40 004b                            cmpi.w    #$4b,d0
$00d8b2 : 660c                                 bne.s     $d8c0
> p pc
Reading debugger commands from 'pc'...
ERROR: No such file or directory
> r
D0: 00000003 D1: 00e00000 D2: 00000004 D3: 0000ffff 
D4: 00000008 D5: 00400000 D6: 00030002 D7: 00000000 
A0: 00003dd8 A1: 00e011ea A2: 00000a87 A3: 00e023c4 
A4: 000028fe A5: ffff8604 A6: ffff8606 A7: 00003dd2 
USP=00000000 ISP=00003dd2 MSP=00000000 VBR=00000000
T=00 S=1 M=0 X=0 N=0 Z=0 V=0 C=0 IMASK=3
FP0: 0 FP1: 0 FP2: 0 FP3: 0 
FP4: 0 FP5: 0 FP6: 0 FP7: 0 
N=0 Z=0 I=0 NAN=0
prefetch 00056602
0000d89e: 6602 4e68 43fa 0040 3018 BNE.B #$00000002 == 0000d8a2 (TRUE)
next PC: 0000d8a0
> d
$00d8b4 : 0c50 0000                            cmpi.w    #0,(a0)
$00d8b8 : 6706                                 beq.s     $d8c0
$00d8ba : 0c50 0003                            cmpi.w    #3,(a0)
$00d8be : 6614                                 bne.s     $d8d4
$00d8c0 : d040                                 add.w     d0,d0
$00d8c2 : d040                                 add.w     d0,d0
$00d8c4 : d2c0                                 adda.w    d0,a1
$00d8c6 : 4a91                                 tst.l     (a1)
> s
$00d8a2 : 43fa 0040                            lea       $d8e4(pc),a1
$00d8a6 : 3018                                 move.w    (a0)+,d0
$00d8a8 : 0c40 0100                            cmpi.w    #$100,d0
$00d8ac : 6426                                 bcc.s     $d8d4
$00d8ae : 0c40 004b                            cmpi.w    #$4b,d0
$00d8b2 : 660c                                 bne.s     $d8c0
$00d8b4 : 0c50 0000                            cmpi.w    #0,(a0)


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