I have been a bit distracted over the last couple of weeks with another task but this is the technique I had in mind for a roll your own FASTCALL where you have more arguments than the 3 registers that can be used.
In simple terms, a procedure with less than 4 arguments can use EAX ECX & EDX.
With a technique posted below in an earlier post you can simulate locals with .DATA? section variables.
The technique below uses a structure for procedures that require more than 3 arguments.
The gains are a stack free procedure that does not need the complex stack offset changes common in no-stack frame procs, the extra register EBP is easily available if needed, the equivalent of LOCALS work fine and with the use of a structure, the argument count limit does not matter.
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include\masm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
fcargs STRUCT
arg1 dd ?
arg2 dd ?
arg3 dd ?
arg4 dd ?
arg5 dd ?
arg6 dd ?
arg7 dd ?
arg8 dd ?
fcargs ENDS
.data?
pMessageBox dd ?
pLib dd ?
.data
tMsg db "This is a message box",0
pMsg dd tMsg
tTtl db "MessageBox",0
pTtl dd tTtl
.code
start:
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
call main
exit
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
main proc
LOCAL astruct :fcargs
mov pLib, rv(LoadLibrary,"user32.dll")
mov pMessageBox, rv(GetProcAddress,pLib,"MessageBoxA")
m2m astruct.arg1, pMessageBox ; function address
mov astruct.arg2, 0 ; handle
m2m astruct.arg3, pMsg ; text message
m2m astruct.arg4, pTtl ; dialog title
mov astruct.arg5, MB_OK ; style
lea eax, astruct.arg1
call mbox
fn FreeLibrary,pLib
ret
main endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
mbox PROC
push DWORD PTR [eax+16]
push DWORD PTR [eax+12]
push DWORD PTR [eax+8]
push DWORD PTR [eax+4]
call DWORD PTR [eax]
ret
mbox ENDP
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end start