| home
Debugging ASM Major Revision Sept 24, 2000 for new macro library Ever get the feeling writing asm programs is like typing on a keyboard in a small enclosed room at night while blindfolded? With gloves on? You write what you believe to be good code, get the compiler to finally accept it, hit the RUN button, and see... nothing? Or worse, a GPF? You go back to your source code and look... it maybe this, it maybe that, but how to tell? Wouldn't it be nice if you could somehow make a window inside your program to see what is happening? Sure, there is soft ice. It's a find product, but not something I'm interested in using. I don't want to make major changes to my machine just to check some code. I use my computer for many things, some of them just running applications such as spread sheets or CAD programs, and I just don't want any extra overhead running. I want it as light and simple as I can get it. But still, how to get that window inside? Well, there are three simple ways this window could work. Here they are in increasing complexity:
dismissed. No good for say spying on the message loop. information. Can even spy the message loop as items will scroll up and out of it. program did. Must be opened to be viewed. Let me digress a bit first about the display window used. It's just a standard console window, the good old DOS box. It can be a very powereful tool. You can have any windows program open a console by invoking "AllocConsole" to see the messages.But even better is to start your program from a console (even a windows program). Your program will send its messages to this box, and if you start the program with a pipe then the pipe file gets the messages. IE, start myprogram.exe like this: "myprogram.exe >myprogram.txt" and you will get a file of the messages in myprogram.txt. Clean and simple. Here is a list of the debug macro commands inside Dmacros.inc: DPrint TO CONSOLE OR MESSAGEBOX: The DPrint macros
will direct debug information to either
Define one of the following BEFORE the include files area: DEBUGC EQU 1 ; console debug print
DEBUGW EQU 1 ; windows debug
print
DPrint Debug
statements may be added as follows:
DPrint "Message here" ; print a comment
DPrintValD eax, "EAX" ; print a comment
followed by
DPrintValH eax, "EAX" ; print a comment
followed by
DPrintSZ OFFSET szString , "The string is"
To use
console output, use the Console build options of Quick Editor
If the
console app is started from a dos box, the console output
IE,
This command dumps the console output to the file MyApp.txt When using the
windows app option, message boxes will appear. This
Also note, these
functions will work quite happily on displaying
DPrintValH SomeVar, "SomeVar is" ; print a comment followed by
LOGGING TO FILES: The Dlog series
of macros perform the same actions as the DPrint series,
Dlog differs
in that the file must be opened and closed, and appropiate
DLog Debug statements
may be added as follows:
Define the following BEFORE the include files area:
DEBUGL EQU 1 ; console debug
print
DLogStart "MyApp.txt" ; opens the file for information
DLogEnd
; Closes the file, place just before your
DLog "Message here" ; print a comment
DLogValH eax, "EAX" ; print a comment
followed by
DLogSZ OFFSET szString , "The string is"
One final warning. These macros depend on the (at this time) unreleased next version of the masm32 library. Presently, the lib has no DWORD to HEX function, so I wrote one. Hutch says he will add it next release. For now, you will have to add this module yourself with these files. Get Dmacros.zip here |