News:

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

FUNCTION macro

Started by korte, December 10, 2007, 11:03:51 AM

Previous topic - Next topic

korte

I want to create FUNCTION definite macro


calling sample:

FUNCTION xxx,p1,p2,p3

want output

xxx proc p1:DWORD, p2:DWORD, p3:DWORD


my macro (not work)


function MACRO nam:REQ,args:VARARG
      LOCAL cnt
      cnt = 0
     nam
      arg equ <>
      arg CATSTR arg,< proc >

      FOR var,<args>
if cnt gt 0
        arg CATSTR arg,<,var>
else
        arg CATSTR arg,<var>
endif
        cnt = cnt + 1
      ENDM
      arg

    ENDM









korte

Work



function MACRO nam:REQ,args:VARARG
LOCAL cnt
lastproc equ _&nam

ifndef nam
nam macro argss:VARARG
invoke _&nam,argss
endm
endif

      cnt = 0
      arg equ <>
      arg CATSTR arg,<_>
      arg CATSTR arg,<nam >
      arg CATSTR arg,< proc >

      FOR var,<args>
if cnt gt 0
        arg CATSTR arg,<,var:DWORD>
else
        arg CATSTR arg,<var:DWORD>
endif
        cnt = cnt + 1
      ENDM
      arg
    ENDM

_end macro
lastproc endp
endm


function xxx,p1,p2,p3
mov eax,p1
mov eax,p2
mov eax,p3
ret
_end




xxx 1,2,3


korte


The successor is my problem in connection with this.
It occurs that I refer to a function first orderwise, than he is written in the source.
MASM says a syntax error at this time.
How can I ward this off?


u

with a similar macro, that defines the PROTO of this function
Please use a smaller graphic in your signature.

korte

Not use directly invoke, only ose macro.
MASM not found macro if definition after the calling.


    xxx  <- not found this macro


xxx macro

xxx endm