1

Possible Duplicate:
Why do stacks typically grow downwards?

Every architecture I have seen, stack is growing in the way that pushed value is given lower memory address. Is there any reason for that?

Community
  • 1
  • 1
Argbart
  • 19
  • 1
  • Very interesting question! When stacks were first invented, decades ago, RAM was expensive and in short supply. So the stack designers, to shepherd valuable RAM, grew the stack downwards. That meant that less and less RAM was used each time something was pushed onto the stack. – Pete Wilson May 28 '11 at 20:55
  • 1
    @Pete: joking, right? Less and less RAM was _available_ I guess – sehe May 28 '11 at 21:17

1 Answers1

1

The lowest addresses are always reserved for special registers. Picking the lowest ensures that no matter the version of the micro (variable amounts of ram), the special registers are always in the same place.

By starting the stack at the very top, you only need to know one thing. The top address.

It sort of decouples two separate design issues. Reserved register placement and stack origin.

michael
  • 2,577
  • 5
  • 39
  • 62
  • I suggest you expand your answer and add a little clarity. After reading your phrase "The lowest addresses are always reserved for special registers". A newbie to assembly language asked me today "how it possible to use RAM as registers" (obviously you can't - registers are on the CPU, STACK is an area in RAM and RAM is NOT on the CPU). – Ted Feb 22 '14 at 14:08