We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I have been using the 8051 for several weeks. It is not yet clear to me how free space is determined in DATA and how the stack size is determined.
In the SCILABS_STARTUP.A51 file I see that the STACK segment is used to determine the start of the stack, however I can't find the linker file and see how the STACK segment was defined and how its' address is assigned. I also can't find these settings in project settings.
I also see that static variables in functions are declared in DATA. Can anyone give some pointers or a URL on how free space in DATA is determined ? Is it a combination of
Any help would be appreciated.
thanks,
Rochus
http://www.keil.com/support/man/docs/c51/c51_advanced.htm
http://www.keil.com/support/man/docs/bl51/bl51_overlaying.htm
http://www.keil.com/support/man/docs/lx51/lx51_overlaying.htm
Rochus said:SCILABS_STARTUP.A51
You mean SILABS ?
Thanks Andy. Yes I meant SILABS.
Thanks for the URLs.
I guess the summary is:
1) From http://www.keil.com/support/docs/250.htm
The stack typically starts following the last individual variable allocation in internal memory and is free to grow *up* through whatever memory remains. C51 stack usage is minimal.
2) From http://www.keil.com/support/man/docs/lx51/lx51_overlaying.htm
The linker analyzes the structure of the program and creates a call tree which it uses to overlay the data segments containing local variables and function arguments. This technique works extremely well and provides the same efficient use of memory as a conventional stack frame. It is sometimes called a compile-time stack since the stack layout is fixed by the compiler and linker. An advantage of the compile-time stack is that arguments and local variables are accessed directly using fixed memory addresses (which is very fast on the 8051). Typical stack-based accesses are indirect and execute more slowly on the 8051.
So I guess the compile-time stack analysis yields the amount of memory that must be reserved for stack. I am not sure if this is available to the programmer.
As such how does the programmer know how much he/she can allocate to DATA before it conflicts with the stack requirements, without having the linker give you errors ?