This comes back to what I was saying about all these modes and options, it all boils down to really several "supportable" and sensible options
Do pretty much nothing special, RBP frame pointer style / aligned.
option frame:auto
Or the "do everything optimally way"
option frame:auto
option stackbase:rsp
option win64:11
Or possibly the only OTHER option being
option frame:auto
option win64:1
So basically we have 3 modes:
totally dumb, smart, mostly dumb
So when i was saying earlier about removing all those modes perhaps we just replace all this above complex combinatorial stuff with 2 simple directives..
OPTION WIN64:SIMPLE
OPTION WIN64:AUTO
or something like that.
Here is an example of why I think a lot of these modes are irrelevant :
option casemap : none
option frame : auto
option win64 : 11
OPTION STACKBASE : RSP
OptimalProc PROTO aVar : QWORD, bVar : DWORD
AutoProc PROTO aVar : QWORD, bVar : DWORD
AutoProc2 PROTO aVar : QWORD, bVar : DWORD
.code
sub1 proc private frame dest : ptr, src : ptr, val1 : qword, val2 : qword
mov dest, rcx
mov src, rdx
mov val1, r8
mov val2, r9
mov rax, qword ptr[rdx]
add rax, val1
add rax, val2
mov qword ptr[rcx], rax
ret
sub1 endp
getSum proc public frame dest : ptr, src : ptr, val1 : qword, val2 : qword
mov dest, rcx
mov src, rdx
mov val1, r8
mov val2, r9
INVOKE sub1, dest, src, val1, val2
INVOKE AutoProc, 10, 20
INVOKE AutoProc2, 10, 20
INVOKE OptimalProc, 10, 20
ret
getSum endp
; Or using AUTO mode
AutoProc PROC FRAME aVar : QWORD, bVar : DWORD
mov eax, edx
mov rdx, rcx
ret
AutoProc ENDP
; Or using AUTO mode
AutoProc2 PROC FRAME aVar : QWORD, bVar : DWORD
mov eax, edx
mov rdx, aVar
ret
AutoProc2 ENDP
; You might find people doing this to create a "bare" zero - overhead procedure.
OPTION PROLOGUE : NONE
OPTION EPILOGUE : NONE
OptimalProc PROC aVar : QWORD, bVar : DWORD
mov eax, edx ; EAX = bVar
mov rdx, rcx ; RDX = aVar
ret
OptimalProc ENDP
OPTION PROLOGUE:DEFAULTPROLOGUE
OPTION EPILOGUE:DEFAULTEPILOGUE
end
We have 3 procs, OptimalProc which is coded in the way some might to ensure minimal overhead (ie: optimal call), and two version of the same proc using the win64:11 / RSP combination.
AutoProc:
8B C2 mov eax,edx
48 8B D1 mov rdx,rcx
C3 ret
AutoProc2:
48 89 4C 24 08 mov qword ptr [aVar],rcx
8B C2 mov eax,edx
48 8B 54 24 08 mov rdx,qword ptr [aVar]
C3 ret
OptimalProc:
8B C2 mov eax,edx
48 8B D1 mov rdx,rcx
C3 ret
As you can see, there is no benefit.. the autoproc is just as efficient as the zero-overhead one, and in the case of AutoProc2 where we only reference ONE of the parameters by name, only that is copied to shadow space.
So without all the options, you still have full control inside the proc as to how efficient you want it to be.