News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Useful macro

Started by rags, January 14, 2007, 06:02:35 PM

Previous topic - Next topic

rags

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
God made Man, but the monkey applied the glue -DEVO

stanhebben

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.