How to enable the deb macro for the Masm32 examples
The MasmBasic package adds quite a number of useful functions to the standard Masm32 SDK. The most useful for beginners is probably the deb macro, which allows to monitor registers (eax, ax, al, xmm0, ST(0)…), variables (MyDword, MyReal4, …), and strings (deb 4, "A string at address eax:", $eax) in the console or using MessageBoxes. See here for a full description.
Let’s take one of the advanced examples, the tree demo at \Masm32\examples\exampl04\treedemo. To enable the deb macro,
- install MasmBasic (step by step)
- add the lines marked in red below:
title TreeDemo
comment '*==============================*'
comment '* Programed by Ewayne Wagner *'
comment '* E-MAIL: yooper@kalamazoo.net *'
comment '*==============================*'
if 1
include \masm32\MasmBasic\MasmBasic.inc
; usedeb=0 ; remove the “;” to disable the deb macro in your source
else
.586
.model flat, stdcall
option casemap:none ; Case sensitive
include \MASM32\include\Windows.inc
include \MASM32\include\user32.inc
include \MASM32\include\kernel32.inc
include \MASM32\include\gdi32.inc
include \MASM32\include\comctl32.inc
include \MASM32\include\comdlg32.inc
include \MASM32\include\advapi32.inc
includelib \MASM32\lib\user32.lib
includelib \MASM32\lib\kernel32.lib
includelib \MASM32\lib\gdi32.lib
includelib \MASM32\lib\comctl32.lib
includelib \MASM32\lib\comdlg32.lib
includelib \MASM32\lib\advapi32.lib
endif
;===================================================
; PROTO, MACRO, and Data section
;===================================================
…
You are done! From now on, you can add, for example (line 114):
;---------- [Load the Riched20.dll] ----------
INVOKE LoadLibrary, addr RichEdDLL
mov hREdDll, eax
.if !eax ; an error occurred
deb 1, "
.endif LoadLibRichEd",
$Err$() ; MessageBox displaying “Windows has a
problem”