Re: doubt on regarding stacks

From: pmm (muralipmanohar_at_hotmail.com)
Date: 02/24/05


Date: 24 Feb 2005 04:18:56 -0800


dandelion wrote:
> "Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
> news:421dbcd8.68437036@news.individual.net...
> > "pmm" <muralipmanohar@hotmail.com> wrote:
> >
> > > Is there any way to know in which direction stack grows
> >
> > Not in ISO C. In fact, ISO C does not guarantee that you even
_have_ a
> > stack as you understand that term.
>
> Correct, of course, but OTOH, you would have a pretty unusual
platform if
> you did not.
>
> One filthy trick you could employ (with all warnings set abut
> non-portability and compliance) is to
> take the address of some local variable, call a function allocating
another
> local and take that address,too. Then a simple comparison of the
addresses
> would yield the direction in which the stack grows (assuming your
compiler
> does indeed have a stack and uses it).
>
> However, that falls into the "Filthy Tricks" department and you no
> guarantees whatsoever that it will indeed work on your target
platform.
>
> Usually consulting the documentation on your CPU/Compiler will yield
more
> reliable answers.

Thanks for the reply
I sure did the above trick but I felt like a bad practice. I thought of
to have a better code so I posted into this group.

plz let me know the correct concepts. please recommend any web pages
deals with the above concepts
thanks a lot



Relevant Pages

  • Re: Difference between the stack and the heap?
    ... Could someone please illustrate this with some ANSI C code? ... What stack? ... What heap? ... No such things are defined in ISO C. ...
    (comp.lang.c)
  • Re: doubt on regarding stacks
    ... Not in ISO C. ... ISO C does not guarantee that you even _have_ a ... stack as you understand that term. ... Richard ...
    (comp.lang.c)
  • Re: How would you do this in forth?
    ... then compiles the address as a literal. ... stack so you can do something interesting with it later during run ... and execute it with yield. ... so no more dangerous than BEGIN WHILE THEN or DO LOOP;) ...
    (comp.lang.forth)
  • LSE64 - reference
    ... Strings are represented by arrays in which cell 0 is the number of characters and the remaining cells are ... Variables and arrays yield their addresses when executed. ... The flag register is separate from the stack. ...
    (comp.lang.forth)
  • Re: How would you do this in forth?
    ... :} POSTPONE EXIT FORWARD) POSTPONE LITERAL; ... } compiles an EXIT and then compiles the address as a literal. ... yield puts the address on the return stack so it will be returned to. ...
    (comp.lang.forth)