News:

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

Same old, same old: MACROS

Started by TNick, November 23, 2006, 06:29:08 PM

Previous topic - Next topic

TNick

Frustating... maybe there is a complete tutorial or something on build in macros and special symbols that can be used in macros.
Anyway, I need a macro that should be replaced with it's output (a TEXTEQU) at assamble time . This is my macro:

MyStupidMacro      MACRO      String1:REQ,String2:REQ, Arguments:VARARG
LOCAL      strVar_01
LOCAL      strVar_02
     
      % strVar_01      TEXTEQU      <String1&!_!_!_&String2&  TEXTEQU !<>
     
      FOR strVar_02,<Arguments>
            strVar_01      CATSTR  strVar_01,<strVar_02>,<!,>
      ENDM
      strVar_01      CATSTR  strVar_01,<!>>
      % ECHO strVar_01
      % IFDEF <strVar_01>
          % ECHO Redefinition
      ENDIF
       EXITM strVar_01
ENDM

MyStupidMaCRO  Text1, Text2, a100,a101

What I need to be put instead this macro call is
A_Object_Structure___Function1  TEXTEQU <DWORD,DWORD,>
ECHO returns this text ok, but I keep recive this
error A2008: syntax error : MyStupidMaCRO

Thanks,
Nick

TNick

Found it. No EXITM needed at the end!

MyStupidMacro      MACRO      String1:REQ,String2:REQ, Arguments:VARARG
LOCAL      strVar_01
LOCAL      strVar_02
     
      % strVar_01      TEXTEQU      <String1&!_!_!_&String2&  TEXTEQU !<>
     
      FOR strVar_02,<Arguments>
            strVar_01      CATSTR  strVar_01,<strVar_02>,<!,>
      ENDM
      strVar_01      CATSTR  strVar_01,<!>>
      % ECHO strVar_01
      % IFDEF <strVar_01>
          % ECHO Redefinition
      ENDIF
      strVar_01
ENDM

MyStupidMaCRO  Text1, Text2, a100,a101

TNick

But a new question is rising:
How can you find out what type a variable is?
For example:
.DATA
    MyVar   DWORD   0
    MySecondVar    RECT   <>

How cn I know later, in my code, what type MyVar and MySecondVar are?

Nick


TNick

Found answer in Stdlib Macros.Thanks, Randall! :)

PS
Don't mind me! I'm just talking to myself in here...

Nick

zooba

The MASM32 help file contains the most complete macro reference I've seen for MASM. It's worth a read to get to know what operators and directives exist and what they are capable of.

Cheers,

Zooba :U

TNick

Hello, zooba! How are yo my frined? Thanks for reply!
I've read masm32.hlp before starting this thread. The problem is that there should be some more examples about using those macros, I think. Or, maybe, I was a little slow and didn't get that on first reading. Anyway, I'm really thinking about writing a tutorial on those, as soon as I gain some experience with them. :)

Best regards,
Nick

u

When I was studying the macros, apart from reading the masm32.hlp, I had to experiment a lot. Sometimes there should be a % before lines, sometimes % before words (integers), sometimes & before variables, sometimes @CatStr instead of CATSTR.
A bit later I tried doing a macro-"listing" (needs special parameters to ml.exe and those listing-keywords in the .asm) - it explained a bit more how and where macro-variables are created (but ml6.14 sometimes crashes in that case...)
OA32's code is nicely done, so keep it as a reference on how to make macros.
Please use a smaller graphic in your signature.

TNick

Hi, Ultrano!

Quote from: Ultrano on November 27, 2006, 09:39:34 PM
Sometimes there should be a % before lines, sometimes % before words (integers), sometimes & before variables, sometimes @CatStr instead of CATSTR.

I couldn't say it better!  :bg

Quote from: Ultrano on November 27, 2006, 09:39:34 PM
OA32's code is nicely done, so keep it as a reference on how to make macros.
Thanks for the tip, I can't tell why I didn't look inthere!? Maybe just stupid ...  :(

Best regards,
Nick