The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: rags on January 14, 2007, 06:02:35 PM

Title: Useful macro
Post by: rags on January 14, 2007, 06:02:35 PM
Here is a macro I like to use when I have to set one or more registers to zero.
Nothing spectacular, but useful to me, and helps make my code more readable to me. :bg


Clear MACRO args:VARARG
    FOR p,<args>
        xor p, p
    ENDM
ENDM



Usage:

Clear EAX


or


Clear EAX, ECX, EDX


I hope this little macro is as useful to others as it is to me.

regards,
     Rags
Title: Re: Useful macro
Post by: stanhebben on January 14, 2007, 09:42:01 PM
This is my most commonly used macro:

debug macro args:vararg
  pushad
  % print args
  popad
endm

Actually, this one should really be included in the masm macros, I define it in every source file I have.

Usage note: if you use formatting macros like str$, ustr$, hex$, etc, surround them with <>. For example:


  debug "Register eax: "
  debug <ustr$(eax)>, 13, 10


This allows you to quickly set up debug points. I tracked down many bugs this way.