2

I have been recently learning x86 assembly language via GNU Assembler on Ubuntu by the book Programming Ground UP at somewhere on the internet.

There are always 2 sections that's a "Must-Have" when creating a function:

At the beginning, it's considered to save old %ebp and set new frame pointer

pushl %ebp

movl %esp,%ebp

At the end, it's used to restore old %ebp and pop out return address

movl %ebp, %esp

popl %ebp

ret

please help me know what's really happen and what's that used for. - Why they must copy the bottom-most stack pointer to %ebp to set a new frame pointer? - And why the must copy back the %ebp to %esp when done ? - When copy without ( ) is that just an address ?

Thanks.

Paul R
  • 202,568
  • 34
  • 375
  • 539
Little Jack
  • 558
  • 4
  • 14

1 Answers1

-1

This is a function perilogue. The Frequently Given Answer giving the gen on function perilogues explains what's happening, stack frames, and the frame pointer register.

JdeBP
  • 2,026
  • 16
  • 24
  • THanks, the link is very useful. Perhaps, at 1st I didn't know what they call it. – Little Jack May 25 '11 at 14:45
  • 4
    I've downvoted this because it is effectively a link only answer that offers no information. If the link dies this answer is unusable. I'd remove the downvote if a summary of the information that answers the OPs specific question appeared directly in the answer – Michael Petch Aug 15 '16 at 13:56