News:

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

Auto-declaration of externals in POASM

Started by Vortex, January 13, 2006, 07:55:19 PM

Previous topic - Next topic

Vortex

Here is another version of the invoke macro simulator, this new one can handle C functions :

@ArgCount MACRO arglist:VARARG
LOCAL count
count = 0
FOR arg, <arglist>
count = count + 1
ENDM
EXITM count
ENDM

@ArgI MACRO index:REQ, arglist:VARARG
LOCAL count, retstr
count = 0
FOR arg, <arglist>
count = count + 1
IF count EQ index
retstr TEXTEQU arg
ENDIF
ENDM
EXITM retstr
ENDM

_invoke MACRO functionname:REQ,args:VARARG
LOCAL arg,pos,paramcount,count
paramcount=@ArgCount(args)
count=4*paramcount

WHILE paramcount

arg TEXTEQU @ArgI(paramcount,args)
pos=@InStr(1,arg,<ADDR>) OR @InStr(1,arg,<addr>) OR @InStr(1,arg,<Addr>)
IF pos
IF ( OPATTR arg ) AND 64 ; is arg relative to stack?
lea eax,[arg]
push eax
ELSE
            push OFFSET @SubStr(arg,pos+5)
ENDIF
ELSE
push arg
ENDIF
paramcount = paramcount - 1
ENDM

call functionname
     
IF (OPATTR(functionname)) EQ 293 ; is it a C function?
IF count NE 0
add esp,count
ENDIF
ENDIF

   ENDM

[attachment deleted by admin]