macro push arg {
push arg
if defined PUSH_COUNTER
PUSH_COUNTER=PUSH_COUNTER+1
end if
}
macro pop arg {
pop arg
if defined PUSH_COUNTER
PUSH_COUNTER=PUSH_COUNTER-1
end if
}
macro proc name, [arg] {
common
if used name | defined INCLUDE_ALL_PROCS
PROC_NAME equ name
PARAM_COUNTER equ 0
LOCAL_COUNTER equ 0
PUSH_COUNTER=0
if ~ arg eq
forward
PARAM_COUNTER equ PARAM_COUNTER+1
arg equ esp+(PARAM_COUNTER+LOCAL_NUM+PUSH_COUNTER)*4
common
name#% = PARAM_COUNTER
else
name#% = 0
end if
name:
}
macro begin {
LOCAL_NUM=LOCAL_COUNTER
if LOCAL_NUM>0
sub esp, (LOCAL_NUM*4)
end if
}
macro return {
if PUSH_COUNTER<>0
display 'WARNING: push/pop miscount',13,10
end if
if LOCAL_NUM>0
add esp, (LOCAL_NUM)*4
end if
PARAM_NUM=PARAM_COUNTER
ret (PARAM_NUM*4)
}
macro endp {
if PUSH_COUNTER<>0
display 'WARNING: push/pop miscount',13,10
end if
end if
}
macro ldd name {
name equ esp+(LOCAL_COUNTER+PUSH_COUNTER)*4
LOCAL_COUNTER equ LOCAL_COUNTER+1
}
macro lrd name, dwords {
name equ esp+(LOCAL_COUNTER+PUSH_COUNTER)*4
LOCAL_COUNTER equ LOCAL_COUNTER+dwords
}
macro stdcall proc, [arg] {
common
PARAM_COUNTER = 0
if ~ arg eq
reverse
push arg
PARAM_COUNTER = PARAM_COUNTER+1
common
end if
if proc#% <> PARAM_COUNTER
display 'WARNING: Param miscount',13,10
end if
call proc
}
Usage:
stdcall name, 10, 100
proc name, par1, par2
ldd .Local1 ; local dword
begin
code
return ; U can also have multiple return points
endp
Features:
U can freely use ebp and still have named locals, even pushs/pops won't break your code
Warns if param miscount
Warns if push/pop miscount
Include procs only if used or INCLUDE_ALL_PROCS is defined
Think that was it.. Comments appreciated.