Mail Archives: djgpp/1997/09/29/18:51:01
On 25 Sep 97 at 23:15, M. Schulter wrote:
> Thanks to Andrew Crabtree for a suggestion I used in revising this
> program: using a variable _stacksave to restore the value of %esp at
> the end rather than reseting it after every printf. I'd be curious
Ugh (no offense), but that feelse dangerous to me. You'ld be better
off (IMHO) to do the following (allows for nested calls):
_main:
pushl %ebp
movl %esp,%ebp
; code, unfortuantly, %ebp has just been lost, but it's
; usually not needed anyway
; ...
leave ; equivalent to movl `%ebp,%esp; popl %ebp'
ret
In fact, this is how gcc does it.
> to learn, by the way, if there's any guideline in more ambitious
> programs on how large one should allow the stack to grow, or how
> often one should restore %esp.
Go by your instincts. Remember, you have 256k (default) for your
stack. That's a LOT of functions calls.
Bill
--
Leave others their otherness.
- Raw text -