Debug Macros
-------------------------------------------------------------------------------------------------
Version 1.0 July 20, 1999


Introduction
--------------------------------------------------------------------------------------------------

These files contain a few macros which may or may not be usefull for debugging...
Of course these could probably have been done much better... but they do work at least.
Please send me your comments or sugguestions for improvement.  

All these macros require a debug message viewer to be useful (such as SoftICE or Sysinternal's
DebugView). These are implemented as macros and not as functions so that calling them is as 
simple as possible. To use them all that is necessary to do is to say:
  DebugPrint "Debug Messsage"
  DebugPrintf "Eax = %d", eax
  DebugRegDump 
  DebugGetLastError "Error!", eax==0

To use them, simply add debug.asm to your project, and inclue debug.inc.  To enable the macros, 
simply define the constant DEBUG (on the command line perhaps).  To disable them, simply 
undefine this constant.  This method allows for these to be easily enabled and disabled with
no changes to the code necessary.

Each of these functions will preserve all the registers as well as the flags, so no need to 
worry about that... Using these macros should hopefully have no effect on the code.

This method of using macros can lead to bloat if many of them are used.  Thus, it is intended
only for debugging purposes only and not for actually relesed code.  


Macro Descriptions and Syntaxes:
--------------------------------------------------------------------------------------------------

DebugPrint 		
	Description:	This macro takes a string parameter and passes it do the debuig window.
	Syntax: 		DebugPrint <message>
	Example:		DebugPrint "Testing"
	Output:			> Testing				


DebugPrintf		
	Description:	This macro behaves like printf, and handles multiple arguments.  Like DebugPrint,
					it prints a message to the debug window.
	Syntax:			DebugPrintf <format_string>, v1, v2...
	Example:		DebugPrintf "eax = %X (%dd)", eax, eax
	Output:    		> eax = 12 (18d)


DebugRegDump		
	Description:	This macro prints out the values of the registers to the debug window.
	Syntax:			DebugRegDump
	Example:		DebugRegDump
	Output:			> EAX=00000814   EBX=0063FC14   ECX=CD4D5F00   EDX=00000000
					> ESI=0063FA9C   EDI=00510378   EBP=0063FA84   ESP=0063FA14   EIP=00402F3E
					> CS=0177   DS=017F   SS=017F   ES=017F   FS=4197   GS=0000   FLAGS=00000246


DebugGetLastError	
	Description:	This macro will call the windows function GetLastError, and print out the 
					appropriate error message.  The message is only displayed if the error
					condition is met.
	Syntax: 		DebugGetLastError <message>, <error_condition>
	Example:		DebugGetLastError "Error!!!", eax == 0
	Output:			> Error!!!
					> GetLastError: 57h (ERROR_INVALID_PARAMETER - The parameter is incorrect.)
					
--------------------------------------------------------------------------------------------------
(C) 1999 By Bill
billasm@usa.net
http://asm.tsx.org