China Blue Veins
5/24/2011 9:36:00 PM
In article <irh7kn$etq$1@speranza.aioe.org>, Simon <anon@nospam.com> wrote:
> Hi there:
>
> I know this is a very fundamental question. I am still quite confused
> if the program call stack stack should always grow upwards from the
> bottom, or the opposite, or doesn't matter??
It doesn't matter. Some machines go down, others go up.
Before VM was widespread, it was customary to put code, statics, and then the
heap growing up from low memory, and the stack at high memory growing down. If
the two collided, the program would die. Sometimes horribly. With VM it really
doesn't matter since virtual addresses have little relation to real addresses.
> That means the stack pointer should go upwards when there are "push"
> operations,
> and stack pointer should go downards when there are "pop" operations??
This varies. Also varying is whether the SP is the first available stack space
or the latest allocated space. So all of these occur:
push pop
*++sp = value value = *sp--
*sp++ = value value = *--sp
*--sp = value value = *sp++
*sp-- = value value = *++sp
--
I remember finding out about you, | I survived XYZZY-Day.
Everyday my mind is all around you,| I'm whoever you want me to be.
Looking out from my lonely room |Annoying Usenet one post at a time.
Day after day. | At least I can stay in character.