Reply by Anders Lindgren June 8, 20092009-06-08
Franco Bucafusco wrote:
> I would like to know if IAR brings to the user some way to know the start
> address of the stack as well its size.
> I know that project options gives you the chance to change the size, but
> also I would like some way to know it at compiler time.

Hi Franco!

It is possible to get the beginning and end of the stack using the
built-in functions __segment_start and __segment_end.

Note that the stack size is decided at link-time, as it decided by the
linker command file.

For, example, the following will fill the stack with garbage before
launching the application:

#pragma segment="CSTACK"

void the_application(void);

void main()
{
unsigned short *p = __segment_begin("CSTACK");
while (p != __segment_end("CSTACK"))
{
*(p++) = 0xAAAA;
}

the_application();

/* Note: Don't return from "main", the return address has been
* trashed. */
}
-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.

Beginning Microcontrollers with the MSP430

Reply by Franco Bucafusco June 4, 20092009-06-04
Hi!
I would like to know if IAR brings to the user some way to know the start
address of the stack as well its size.
I know that project options gives you the chance to change the size, but
also I would like some way to know it at compiler time.

thanks.