www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/23/09:00:33

From: "Mark S. Novojilov" <novojilo AT explorer DOT uni-trier DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Asm Question
Date: Fri, 19 Sep 1997 01:32:07 +0200
Organization: Universitaet Trier
Lines: 36
Message-ID: <3421B9F7.439E9C68@explorer.uni-trier.de>
References: <Pine DOT LNX DOT 3 DOT 91 DOT 970916120927 DOT 905A-100000 AT aditya DOT unigoa DOT ernet DOT in>
NNTP-Posting-Host: sliphost4177.uni-trier.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gurunandan R. Bhat wrote:

> Greetings,
>
> In what precise way does %ebp "characterise" a stack frame? Does it point
> to the first address on the current stack frame? If so shouldn't each
> nested procedure call redefine %ebp to set up a new stack frame for its
> use?
>
> I have looked at some .s files produced by gcc and all they do is push and
> pop %ebp at each procedure call. Where is it initialised if at all? I
> suspect that this is done in crt0.s but would be grateful for the range
> of line numbers in the relevant file where this is accomplished
>
> Many thanks in advance

  A standard entry to a function looks like:
pushl %ebp
movl %esp,%ebp <---- initializes ebp
...
at the end:
leave
ret

You allways get this picture if you compile
your programs with -standrad-stack-frame option, or something
like that. With this option all locals are accessed through %ebp,
but that means you have one register less for other purposes.
Compiler also can use %esp for accessing locals(more sophisticated),
then %ebp is used as a general purpose register or for whatever
purposes, and the compiler just make sure to restore previous ebp
after function leaves.

                         - Mark


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019