News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Easy debugging

Started by jj2007, April 07, 2025, 07:59:52 AM

Previous topic - Next topic

jj2007

The deb macro is part of MasmBasic. It allows to follow closely any changes of registers (reg32, xmm*, ST*), local or global variables in the console. With usedeb=0, no code will be generated, which means you can leave the deb lines forever in your code.

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals MyGlobalInt=12345, MyGlobalR10:REAL10=3.1415926535897932384626433832795
  SetGlobals MyGlobalQ:QWORD, MyGlobalR8:REAL8, My$="Hello World"
  Init
  ; usedeb=0 ; don't create any code
  Print cfm$("\n\nTesting the deb macro:\n")
  fld MyGlobalR10 ; put PI on the FPU
  fmul FP4(1000000000.0) ; multiply with one Billion   
  fst MyGlobalR8 ; save as REAL8
  fistp MyGlobalQ ; and as QWORD
  movlps xmm1, MyGlobalR8 ; move the double into xmm1
  mov eax, 1234567890 ; registers can be displayed, of course
  movd xmm2, eax
  fldpi ; put PI once more on the FPU
  deb 4, "Some results:", eax, x:esp, MyGlobalQ, MyGlobalR10, f:xmm1, xmm2, ST(0), $My$
  xor ecx, ecx
  .Repeat
    deb 7, "The counter:", ecx ; show only 7 iterations
    inc ecx
  .Until ecx>999999
  pop edx
  Inkey "debugging is easy, right?"
EndOfCode

Testing the deb macro:

Some results:
eax            1234567890
x:esp          0019FF74
MyGlobalQ      3141592654
MyGlobalR10    3.141592653589793238
f:xmm1          3141592653.589793
xmm2            1234567890
ST(0)          3.141592653589793238
$My$            Hello World
The counter:    ecx            0
The counter:    ecx            1
The counter:    ecx            2
The counter:    ecx            3
The counter:    ecx            4
The counter:    ecx            5
The counter:    ecx            6
debugging is easy, right?

Prefixes:
x:eax  display as hex
b:eax  display in binary format
$eax   display as string
f:xmm1 interpret as double (no prefix=integer)