Because Intel's PUSH instruction decrements the stack pointer. POP
increments it. It makes clear sense for Intel machines to have a downward
growing stack: the hardware was designed that way ... Windoze and Linux
both have downstacks. However, ESAME (and its predecessor) machines don't
even have a hardware stack, so I'd presume there are lots of little things
that went into the decision.
The OS/390 C compiler guys were telling me a couple of years ago
(pre-XPLINK) that a downward growing stack on OS/390 would be ever so
slightly more efficient than an upward growing one. The numbers since
XPLINK's implementation show that to be true, but only ever so slightly.
The gcc package can be configured to have the stack grow either way, and if
my light perusals of the kernel code (and my memory) are right, so can
Linux. I would have to think that the final decision would have to do with
memory mapping, guard pages, and vmm controls, as well as the stack frame
format & register mapping, of course -- more or less a matter of choice on
ESAME hardware. I don't know why a downstack was chosen. Fortunately, there
are people who chime in on this list all the time who have the definite
answers. If they'd care to share them, I'm kind of curious too. :-)
--Jim--
James S. Tison
Senior Software Engineer
TPF Laboratory / Architecture
IBM Corporation
[EMAIL PROTECTED]
Greg Smith
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
.epa.gov> cc:
Sent by: Linux on Subject: Re: Probably the first
published shell code example for Linux/390
390 Port
<[EMAIL PROTECTED]
IST.EDU>
10/31/2002 15:03
Please respond to
Linux on 390 Port
Ward, Garry wrote:
> Simplicity?
>
> push something to the stack, decrement the address, and if you've gone
> negative, you've gone too far?
>
> PUSH
> DEC
> BN stack overrun
> BZ stack overrun
>
>>
>> I've always been curious. Why is a top down stack used anyways ??
I understand that much.... but why did Intel want you to use a top-down
stack ?? I remember from my Pascal days that you could reference your
caller's local variables, so I guess it's easier to reference them in a
top-down stack. Just a guess, I have no idea.
Greg