Re: Direction of Stack Growth



On Oct 23, 11:25 am, karthikbalaguru <karthikbalagur...@xxxxxxxxx>
wrote:
On Oct 23, 11:33 am, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx>
wrote:





Archi wrote:

(I wrote)

Many systems now access arguments as positive index off
the stack pointer, and local variables as negative
index off the stack pointer. (or frame pointer.)
sorry, no way with hardware stack pointer. Do not forget that there are
uncontrollable events like interrupts, so stack should be completely
"down" all the time - there is no need for negative indexes. If you use
frame pointer - then yes? but you pay wit extra register and "entry" code.

Most now have a separate stack for interrupts and other system
functions, pretty much needed for any protected mode system.

I do remember from the 8080 days someone working on the
design of a terminal. It was found that the fastest way to
clear the screen memory was to point the stack pointer at
one end of the buffer and push blanks. Mysterious characters
kept appearing on the screen, though, which turned out to be
due to interrupts during the clear loop.

-- glen

Check this out.http://kstruct.com/2007/04/16/interview-questions-stack-direction/

Interesting :)
1) The author claims as below in that link -
"Wikipedia tells me that most modern OSes grow the stack down which
is odd given the security advantages of doing it up."
Is that true or some kind of wrong information in internet ?

2) But i liked the 'C' program that helps in finding the direction of
stack growth.
3) I also like the shell script mentioned in the link ->http://www.splode.com/~friedman/software/scripts/src/stack-direction

Thx in advans,
Karthik Balaguru- Hide quoted text -

- Show quoted text -

I posted that from my query regarding 'Direction of Stack Growth'
posted in other groups.
I saw that i missed comp.os.linux.embedded and hence posted it here.

Kindly share your ideas in the following link :
http://groups.google.co.in/group/comp.arch.embedded/browse_thread/thread/001243efba95ebc0/?hl=en#

Thx,
Karthik Balaguru


.



Relevant Pages

  • Re: Direction of Stack Growth
    ... index off the stack pointer. ... frame pointer - then yes? ... stack growth. ... Karthik Balaguru- Hide quoted text - ...
    (comp.os.linux.embedded)
  • Re: Is there stack associated when a executing an inline function?
    ... moves the stack pointer by some delta to enlarge the current frame, ... then references all of its locals with respect to the current frame, ...
    (comp.lang.c)
  • Re: need help with stack pointers
    ... subtract the offset value from the current stack pointer value to get the ... You can see evidence of this when the BSR instruction subtracts from the stack pointer as it pushes a return address, and the RTS instruction adds to the stack pointer as it pops that address back into PC. ... So if you're going to establish a frame on "top" of such a stack, you have to avoid the higher addresses which are already in use, and put your frame in locations below the current SP value. ... It would be possible to locate a "frame base" one frame size below the SP value, get that in a register, and index up from there, but that wastes a register for no benefit. ...
    (comp.arch.embedded)
  • Re: [9fans] pointer to the last TOS
    ... the stack pointer is there. ... a positive offset from ... pointer to the virtual frame pointer to find the return address. ...
    (comp.os.plan9)
  • Re: Is there stack associated when a executing an inline function?
    ... frame since there is no function call. ... moves the stack pointer by some delta to enlarge the current frame, ... jacob at jacob point remcomp point fr ...
    (comp.lang.c)