News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Quick procedure definition macros

Started by Vortex, March 30, 2024, 08:50:14 PM

Previous topic - Next topic

Vortex

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

sinsi

Unlikely, but what if arguments is blank?
Windows 11 is better :tongue: but 98SE was the bee's knees

Vortex

Hi sinsi,

If there are no arguments, it means that the procedure does not take any parameters so no need to use the macro.

sinsi

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?
Windows 11 is better :tongue: but 98SE was the bee's knees

Vortex

Hi sinsi,

invoke InitCommonControls
This call has nothing to do with my macro. InitCommonControls is a procedure stored in comctl32.dll

sinsi

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?

Windows 11 is better :tongue: but 98SE was the bee's knees

Vortex

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

Vortex

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.