Re: doubt on regarding stacks

From: Neil Kurzman (nsk_at_mail.asb.com)
Date: 02/25/05


Date: Fri, 25 Feb 2005 04:52:48 GMT


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.
>

many 8bitters the PIC and 8051 for example.

>
> 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.



Relevant Pages

  • 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)
  • Re: How would you do this in forth?
    ... complications that might make it break. ... 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)
  • Re: for or each?
    ... By 'scope' do you mean 'stack frame'? ... The only 'objects' being created here are stack frames, ...
    (comp.lang.ruby)