delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/29/18:51:01

Date: Tue, 30 Sep 1997 10:47:32 +1100
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: DJGPP humor: lightyr.s (long long)
In-reply-to: <60er9u$5qp$2@vnetnews.value.net>
To: "M. Schulter" <mschulter AT value DOT net>, djgpp AT delorie DOT com
Message-id: <199709292252.KAA06121@teleng1.tait.co.nz gatekeeper.tait.co.nz>
Organization: Tait Electronics Limited
MIME-version: 1.0
Comments: Authenticated sender is <billc AT blackmagic DOT tait DOT co DOT nz>

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 -


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