EasyManua.ls Logo

Intel ARCHITECTURE IA-32 - Example D-2 Aligned Ebp-Based Stack Frames

Intel ARCHITECTURE IA-32
568 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Stack Alignment D
D-7
Example D-2 Aligned ebp-based Stack Frames
void _stdcall foo (int k)
{
int j;
foo:
push ebx
mov ebx, esp
sub esp, 0x00000008
and esp, 0xfffffff0
add esp, 0x00000008 // esp is (8 mod 16)
after add
jmp common
foo.aligned:
push ebx // esp is (8 mod 16)
after push
mov ebx, esp
common:
push ebp // this slot will be
used for
// duplicate return pt
push ebp // esp is (0 mod 16)
after push
// (rtn,ebx,ebp,ebp)
mov ebp, [ebx + 4] // fetch return pointer
and store
mov [esp + 4], ebp // relative to ebp
// (rtn,ebx,rtn,ebp)
mov ebp, esp // ebp is (0 mod 16)
sub esp, 28 // esp is (4 mod 16)
//see Note A
push edx // esp is (0 mod 16)
after push
continued

Table of Contents

Related product manuals