News:

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

Procedure calling methods

Started by gabor, February 13, 2006, 03:55:23 PM

Previous topic - Next topic

gabor

Hi!


I bumped into this several times mention: how to pass parameters to a procedure via MACRO with VARARG?


@caller MACRO functionName:REQ,arg:VARARG

        FOR arg,<args>
            push DWORD PTR arg
        ENDM
        call functionName
ENDM


The problem is that pushing the arguments this way is just the reverse order compared to the default calling convention.

So far, I've found a solution: I have to declare every functions that I want to call via this macro with PASCAL keyword.
What do you think of this? Is this a good idea at all? Are there any drawbacks?

Greets, Gábor

Ratch

gabor,
     You might find this link interesting.  Read it and decide for yourself which way is best.  Note how the macro INVOKIT uses another macro called RPUSHIT to reverse the order of parameters pushed onto the stack.  Ratch  http://www.masmforum.com/simple/index.php?topic=99.0