Page 1 of 2
Debug register
Posted: Sat Jan 07, 2006 11:09 pm
by mdp
To see the content of a register is pretty easy
Code: Select all
Global deb
; ... my ASM code ...
!MOV dword [v_deb],ebx
Debug deb
But still a little too tricky
Is it possible to have a direct something like
Thanks
Posted: Sun Jan 08, 2006 1:45 pm
by Kale
See the OnError lib:
or
Menu:Debugger-->Assembly

Posted: Sun Jan 08, 2006 4:09 pm
by Trond
Tried the assembly debugger combined with a breakpoint?
Posted: Sun Jan 08, 2006 7:07 pm
by Fred
yes, the debugger support assembly register display so it should work.
Posted: Sun Jan 08, 2006 9:48 pm
by mdp
@kale
Well,
Code: Select all
!MOV eax,123
Debug GetErrorRegister( #PB_OnError_EAX )
returns 0...
The problem is that also
Code: Select all
!MOV eax,123
a=GetErrorRegister( #PB_OnError_EAX )
Debug a
returns 0

Maybe the command works only in case of error? Sorry, I'm not used to the OnError commands.
@Trond, @Fred
the Debug command, compared to the assembly debugger window, has the feature of the flow of data - you can see all the values at the same time. Since they can be thousands, it's more comfortable than writing them down step by step.
If I may add (your prompt responses anticipated an edit-addendum for my post), the Debug command does not preserve the register situation when it is called, so - in the way I showed at the top - it 'breaks' the rest of the code.
So, I would also like to suggest that 'Debug' would restore the eax,ebx etc. contents after it is called.
Posted: Mon Jan 09, 2006 1:13 pm
by Rings
mdp wrote:
The problem is that also
Code: Select all
!MOV eax,123
a=GetErrorRegister( #PB_OnError_EAX )
Debug a
returns 0

Maybe the command works only in case of error? Sorry, I'm not used to the OnError commands.
exactly, if an error is catched, a register-snapshot is taken.
Posted: Mon Jan 09, 2006 1:55 pm
by Fred
About 'Debug' preserving all the registers, it's a good idea, we will add it.
Posted: Mon Jan 09, 2006 2:55 pm
by Kale
Fred wrote:About 'Debug' preserving all the registers, it's a good idea, we will add it.
Can we have this too please?
viewtopic.php?t=18478 
Posted: Mon Jan 09, 2006 4:44 pm
by Trond
Can you use something like this?
Code: Select all
!mov eax, 5
!call deax
!call deax
!add eax, eax
!call deax
End
!deax:
!push eax
!mov [v_asmdebug_32b], eax
Debug asmdebug_32b
!pop eax
!ret
Posted: Tue Jan 17, 2006 8:51 pm
by Trond
Also it would be nice if Debug didn't clear GetLastError_().
Posted: Tue Jan 17, 2006 11:38 pm
by Fred
In the v4, it doesn't use any API anymore, so it shouldn't clear the GetLastError_().
Posted: Sat Jan 21, 2006 2:35 pm
by Trond
Another suggestion for the debugger: If debugging a string, do a new line for CRLF.
Posted: Mon Feb 20, 2006 5:54 pm
by mdp
It seems that the answer to my post could in PB4 be the following:
Code: Select all
Macro Deb_EBX
MOV dword [v_debvar],ebx
PUSH eax : PUSH ebx : PUSH ecx : PUSH edx : PUSH ebp
Debug debvar
POP ebp : POP edx : POP ecx : POP ebx : POP eax
EndMacro
;e.g.
MOV ebx,345
Deb_EBX
INC ebx
Deb_EBX
Could, because I don't know exactly which registers to preserve

Some lines in the forthcoming documentation will be appreciated (if not the specification of the registers used by every pb command)
Posted: Mon Feb 20, 2006 7:40 pm
by Trond
About 'Debug' preserving all the registers, it's a good idea, we will add it.
Did you forget it or just not high enough prioritized amongst all the other features?
Code: Select all
Global _regout
Macro regout(reg)
!push eax
!push ecx
!push edx
!mov edx, reg
!mov [v__regout], edx
Debug _regout
!pop edx
!pop ecx
!pop eax
EndMacro
!mov eax, 464
regout(eax)
regout(eax)
!add eax, eax
!mov ebx, eax
regout(ebx)
regout(ebx)
For all 32-bit general purpose registers:
eax, ebx, ecx, edx, esi, edi, ebp and esp.
Posted: Mon Feb 20, 2006 7:44 pm
by Fred
Using pushad/popad is probably a bit faster to write when you want to preserve all the registers

.