使用宏实现类似masm invoke
第一种方法:
使用重载的多行宏,然后根据参数不同实现不同
;当参数为1的时候直接调用函数
;call _printf
;invoke _printf
%macro invoke 1
call %1
%endmacro
;当有参数的时候,2个参数或更多参数
%macro invoke 2-*
;定义一个单行宏为函数名称
%define _j %1
;重复次数为参数-1个
%rep %0-1
;向左转%1
%rotate -1
;向左转%1就表示了最后一个参数,最后第二个参数,最后第三个参数...
push dword %1
%endrep
;一个循环以后参数就从后往前压入了栈
;再调用函数名
call _j
%endmacro
第二种方法
;多于一个参数,然后使用预处理的%if根据不同的参数来处理
%macro invoke 1-*
%if %0==1
call %1
%else
%define _j %1
%rep %0-1
%rotate -1
push dword %1
%endrep
call _j
%endif
%endmacro