The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ecube on May 02, 2009, 12:39:33 AM

Title: Simple macro help
Post by: ecube on May 02, 2009, 12:39:33 AM

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
Title: Re: Simple macro help
Post by: qWord on May 02, 2009, 12:51:02 AM
hi,
in macros you have to use other comparison operators: EQ,LE,GE,NE,GT,LT
--> WHILE cnt LT num
Title: Re: Simple macro help
Post by: ecube on May 02, 2009, 01:39:28 AM
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.
Title: Re: Simple macro help
Post by: MichaelW on May 02, 2009, 02:09:58 AM
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