The MASM Forum

Projects => Poasm => Topic started by: Vortex on March 30, 2024, 08:50:14 PM

Title: Quick procedure definition macros
Post by: Vortex on March 30, 2024, 08:50:14 PM
QPROC ( Quick procedure ) macro :

QPROC MACRO fname:REQ,arguments:VARARG

LOCAL temp

    temp TEXTEQU <>

    FOR arg,<arguments>
   
        temp CATSTR temp,<arg>,<:DWORD,>

    ENDM

    fname PROC @SubStr(temp,1,@SizeStr(temp)-1)

ENDM

Replacing the traditional procedure definition :

WinMain PROC hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
QPROC WinMain,hInst,hPrevInst,CmdLine,CmdShow
Title: Re: Quick procedure definition macros
Post by: sinsi on March 30, 2024, 09:21:22 PM
Unlikely, but what if arguments is blank?
Title: Re: Quick procedure definition macros
Post by: Vortex on March 30, 2024, 09:28:00 PM
Hi sinsi,

If there are no arguments, it means that the procedure does not take any parameters so no need to use the macro.
Title: Re: Quick procedure definition macros
Post by: sinsi on March 30, 2024, 09:48:36 PM
That's why I said unlikely, but consider how many people use
    invoke InitCommonControls
Just curious, but which part would poasm throw an error? The FOR part or @SubStr?
Title: Re: Quick procedure definition macros
Post by: Vortex on March 30, 2024, 09:53:18 PM
Hi sinsi,

invoke InitCommonControls
This call has nothing to do with my macro. InitCommonControls is a procedure stored in comctl32.dll
Title: Re: Quick procedure definition macros
Post by: sinsi on March 30, 2024, 10:36:22 PM
OK, poor example, it was just to illustrate that people follow habits, so if they see a lot of QPROCs they might think that's the way to do it.

WinMain PROC hInst,hPrevInst,CmdLine,CmdShow
QPROC WinMain,hInst,hPrevInst,CmdLine,CmdShow
Not a great deal of difference - or does poasm expect the size as well?

Title: Re: Quick procedure definition macros
Post by: Vortex on March 31, 2024, 07:29:04 PM
Hi sinsi,

Jochen informed me about the case, this declaration is accepted by Poasm so my macro is useless :

WinMain PROC hInst,hPrevInst,CmdLine,CmdShow
Title: Re: Quick procedure definition macros
Post by: Vortex on March 31, 2024, 07:33:42 PM
This is for Poasm 64-bit, the PROCX macro sets automatically the PARMAREA value   :

PROCX MACRO functionname:REQ,args:VARARG

fname TEXTEQU functionname

    functionname PROC args PARMAREA=16*QWORD

ENDM

ENDPX MACRO

    fname ENDP

ENDM

The maximum number of parameters ( 16 by default ) can be modified easily.