Intel ARCHITECTURE IA-32 User Manual Page 543

  • Download
  • Add to my manuals
  • Print
  • Page
    / 568
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 542
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
Page view 542
1 2 ... 538 539 540 541 542 543 544 545 546 547 548 ... 567 568

Comments to this Manuals

No comments