Need for _FREE constant
Ron Czapala
Posts: 2,418
I just bought the Propeller Starter Kit and am trying to figure out why you would ever use the _FREE constant.
The manual says "Use _FREE if an application requires a minimum amout of of free memory in order to run properly".
Being·a newbie regarding the Propeller/Spin/etc, what situation would cause that situation?·
I get _STACK but·wonder about _FREE. A search to Forum didn't help...
Thanks,
· Ron
NOTE: I have downloaded a bunch of objects and a search of those and the Propeller tool folder only revealed one spin file with a _FREE constant.
It was in Graphics_Palette.spin but I' not sure what the comment means:
············ _free = ($3000 + $3000) >> 2········· 'accomodate bitmap buffers··
Post Edited (Ron Czapala) : 7/28/2010 10:24:55 PM GMT
The manual says "Use _FREE if an application requires a minimum amout of of free memory in order to run properly".
Being·a newbie regarding the Propeller/Spin/etc, what situation would cause that situation?·
I get _STACK but·wonder about _FREE. A search to Forum didn't help...
Thanks,
· Ron
NOTE: I have downloaded a bunch of objects and a search of those and the Propeller tool folder only revealed one spin file with a _FREE constant.
It was in Graphics_Palette.spin but I' not sure what the comment means:
············ _free = ($3000 + $3000) >> 2········· 'accomodate bitmap buffers··
Post Edited (Ron Czapala) : 7/28/2010 10:24:55 PM GMT
Comments
You're not alone in your confusion regarding _stack vs. _free. I'm not sure I have it figured out either; and, as you've noticed, the docs aren't much help. What does seem certain is that both constant declarations reserve space at the top of RAM, ending at $7FFF, with the free space residing above the stack. What is less certain is where the stack starts -- at the top of stack space building down or at the bottom building up? And, if it's the latter, does the Spin interpreter have a mechanism to protect the free space from stack overflows? If so, what happens then? And if not, what's the point of having separate declarations? Enquiring minds want to know! TM
-Phil
The compiler and the interpreter do not check for stack overflow. It's possible to add a rough check to your program. FemtoBasic does this since it uses a recursive descent parser for expressions and the stack can grow indefinitely without that.
Thanks for the explanation. I was wondering what would the reserved free space be used for, which Mike indicated buffers and display buffers.
I am really looking forward to delving into the Propller's capabilities. Basic Stamps are fun but rather limited. Arduinos have more memory but need interrupt handling for many situations. The Propeller certainly seems to have the advantage...
-Phil
I think they should be kept separate, since they generally change independently. For example, if I have a project that uses video then the space I need for video buffers may remain constant, but the space need for stack may change several times over the life of the project. Or I may change the resultion of video I use (and hence the size of free space I need) but the stack space remains constant.
Keeping them separate allows me to adjust them as I need to, without having to remember to add them together all the time.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
-Phil