The attached ZIP file is a working example of how to use MACROS to perform argument count checking. Whether or not I could be bothered is another matter but it does work correctly. The macros are easy to replicate from a simple list of API function names with the arg count after them.
For normal statement calls the macro style is as follows.
CreateWindowEx? MACRO args:VARARG
test_arg_count 12,"CreateWindowEx?",args
invoke CreateWindowEx,args
ENDM
For function format calls the macro style is as follows.
SendMessage@ MACRO args:VARARG
.mi test_arg_count 4,"SendMessage@",args : invoke SendMessage,args
EXITM <rax>
ENDM
Cute what you can do with a genuine MACRO assembler that is not trying to be a compiler.
New SDK version?
demo.asm(91) : error A2006:undefined symbol : GdiplusStartup
Hi Hutch,
Another method is to modify the invoke macro to check the argument count :
ExitProcess@ = 1
GetCommandLine@ = 0
GetModuleHandle@ = 1
CreateWindowEx@ = 12
DefWindowProc@ = 4
DispatchMessage@ = 1
GetMessage@ = 4
LoadCursor@ = 2
LoadIcon@ = 2
PostQuitMessage@ = 1
RegisterClassEx@ = 1
ShowWindow@ = 2
TranslateMessage@ = 1
UpdateWindow@ = 1
WndProc@ = 4
WinMain@ = 4
@ArgCount MACRO arglist:VARARG
LOCAL count
count = 0
FOR arg, <arglist>
count = count + 1
ENDM
EXITM %count
ENDM
.
.
invoke MACRO funcname:REQ,args:VARARG
LOCAL paramcount,paramcnt,p,disp,optaddr,stackbytes
.
.
p=@ArgCount(args)
temp TEXTEQU %funcname&@
IF p NE funcname&@
% echo funcname should take temp parameters.
.ERR
ENDIF
Thanks Erol, have it saved where I can find it for when I have enough brain left to digest it.
Quote from: Vortex on April 15, 2017, 06:18:32 AM
ExitProcess@ = 1
GetCommandLine@ = 0
GetModuleHandle@ = 1
CreateWindowEx@ = 12
One could even add the type of the argument:
j@ExitProcess equ 3849/58:s1
j@GetCommandLineA equ 3924/58:s
j@GetModuleHandleA equ 4002/58:s1
j@CreateWindowExA equ 12490/130:s111111111111
j@__toascii equ 5638/76:c6
j@__wgetmainargs equ 5643/76:c6
j@VariantTimeToSystemTime equ 8777/89:s39
(from \Masm32\MasmBasic\Res\pt.inc, October 2016, 585,746 bytes, included here (http://masm32.com/board/index.php?topic=94.0))