The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on December 10, 2007, 11:03:51 AM

Title: FUNCTION macro
Post by: korte on December 10, 2007, 11:03:51 AM
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








Title: Re: FUNCTION macro
Post by: korte on December 10, 2007, 12:00:40 PM
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

Title: Re: FUNCTION macro
Post by: korte on December 10, 2007, 12:06:47 PM

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?

Title: Re: FUNCTION macro
Post by: u on December 10, 2007, 06:20:01 PM
with a similar macro, that defines the PROTO of this function
Title: Re: FUNCTION macro
Post by: korte on December 11, 2007, 07:21:58 AM
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