>In the beginning there were statically allocated variables.
>No heap. No stack. Allocated starting at address 0 or low, and growing up.
>
>Then came stacks. To maximize space, allocated starting at address
>high, and growing down until they met the statics.
A reasonable theory, but it's hard to find support for it. Two
influential machines with stacks were the 1964 vintage PDP-6 (PDP-10,
DEC-20) and the 1969 PDP-11 (VAX). On the PDP-6, stacks grew up, on
the PDP-11, they grew down. Both can do positive or negative index
offsets equally well, no preference there. Bell et al in "Computer
Engineering" note the stack directions but don't give any motivation.
The PDP-11 did a lot of things in what were then seen perverse ways,
notably little-endian addressing. The downward growing stacks might
have partly been that, partly for the idea that the program and heap
are at the bottom of memory, the stack at the top. On the other hand,
the original PDP-11/20 had a stack overflow trap when the stack
crossed location 0400, but the book notes that nobody used it and it
was dropped from later versions.
So your guess is as good as any, but it's still a guess.
Serious stack machines like the B5500 had stacks that grew up, but
since there was no indexing off the stack pointer, the direction was
largely invisible other than to OS memory allocation.
--
Regards,
John Levine,
jo...@iecc.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail.
http://jl.ly