Re: doubt on regarding stacks

From: DHOLLINGSWORTH2 (DHOLLINGSWORTH2_at_cox.net)
Date: 02/26/05


Date: Fri, 25 Feb 2005 22:48:25 -0600


"pmm" <muralipmanohar@hotmail.com> wrote in message
news:1109247536.492114.200430@o13g2000cwo.googlegroups.com...
>
> 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
>

The correct method is to write to the hardware manufacturer, and request the
data sheets for the proccessor your working with. ( don't hesitate to get
the info from the horses mouth.)
 I can just about bet you that it grows away from the base: )