Stack Alignment
D
D-8
// the goal is to make
esp and ebp
// (0 mod 16) here
j = k;
mov
edx, [ebx + 8]
// k is (0 mod 16) if
caller aligned
// its stack
mov
[ebp - 16], edx
// J is (0 mod 16)
foo(5);
add
esp, -4
// normal call sequence
to
//
unaligned
entry
mov [esp],5
call foo
// for stdcall, callee
// cleans up stack
foo.aligned(5);
add esp,-16
// aligned entry, this
should
// be a multiple of 16
mov [esp],5
call foo.aligned
add esp,12
// see
Note B
return j;
mov eax,[ebp-16]
pop edx
mov esp,ebp
pop ebp
mov esp,ebx
pop ebx
ret 4
}
Example D-2 Aligned ebp-based Stack Frames
(continued)
Summary of Contents for ARCHITECTURE IA-32
Page 1: ...IA 32 Intel Architecture Optimization Reference Manual Order Number 248966 013US April 2006...
Page 220: ...IA 32 Intel Architecture Optimization 3 40...
Page 434: ...IA 32 Intel Architecture Optimization 9 20...
Page 514: ...IA 32 Intel Architecture Optimization B 60...
Page 536: ...IA 32 Intel Architecture Optimization C 22...