News:

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

Simple macro help

Started by ecube, May 02, 2009, 12:39:33 AM

Previous topic - Next topic

ecube


DoMath MACRO num:REQ
LOCAL cnt
      cnt = 0
      WHILE cnt < num
      cnt = cnt + 1
      .code
      add ecx,4
      sub edx,4
      ENDM
ENDM


can't get this to work, tryed just DoMath 5 in hopes it'll generate add ecx,4 and sub edx,5, 5 times in a row, i'm code speed testing and don't feel like typing same stuff over and over. any hints?

error says missing angle bracket or brace or literal

qWord

hi,
in macros you have to use other comparison operators: EQ,LE,GE,NE,GT,LT
--> WHILE cnt LT num
FPU in a trice: SmplMath
It's that simple!

ecube

thanks qword, I managed to get workin with

     cnt = num
      WHILE cnt
      cnt = cnt -1

but it's good to know the comparisons, I looked at macros.asm in masm's folder and didn't see what I was lookin for.

MichaelW

If the value of cnt will not be encoded into an instruction, why not just use something like:

REPEAT num
    add ecx, 4
    sub edx, 4
ENDM

eschew obfuscation