28h
から減算される (10 進数 40)の値はrsp
、次のように計算されます。
option casemap:none
includelib kernel32.lib
includelib user32.lib
externdef MessageBoxA : near
externdef ExitProcess : near
.data
text db 'Hello world!', 0
caption db 'Hello x86-64', 0
.code
main proc
sub rsp, 28h ; space for 4 arguments + 16byte aligned stack
xor r9d, r9d ; 4. argument: r9d = uType = 0
lea r8, [caption] ; 3. argument: r8 = caption
lea rdx, [text] ; 2. argument: edx = window text
xor rcx, rcx ; 1. argument: rcx = hWnd = NULL
call MessageBoxA
xor ecx, ecx ; ecx = exit code
call ExitProcess
main endp
end
から: http://www.japheth.de/JWasm/Win64_1.html
私の理解では、20h
使用している各値は 8 バイトから 4 であるため、減算するだけで済みます20h
。では、なぜ が28h
減算され、それがどのようにして 16 バイトのアラインメントになるのでしょうか?
引数が 4 つ未満の関数にはスタック領域の予約が必要ですか?も参照してください。