Stack Posers
CannibalRobotics
Posts: 535
Two questions about the stack:
1) A stack length object can approximate the stack size by stuffing the stack then watching where the changes are made. What about the top object. Will it just step on child objects as memory is needed?
2) Say you have three simple, non-recursive objects called sequentially. Each one needs 9 longs of stack space. Is the allocation for those 9 or 27. If 27, what causes the pointer to reset or adjust itself back down? (Please put pointer access into the next prop!)
Thanks,
Jim-
1) A stack length object can approximate the stack size by stuffing the stack then watching where the changes are made. What about the top object. Will it just step on child objects as memory is needed?
2) Say you have three simple, non-recursive objects called sequentially. Each one needs 9 longs of stack space. Is the allocation for those 9 or 27. If 27, what causes the pointer to reset or adjust itself back down? (Please put pointer access into the next prop!)
Thanks,
Jim-
Comments
The stack resource is released after the process is run. I can't remember where I read this the Propeller manual or the PE Kit or both.
Prop 1 has pointer access. What are you looking for?
Where? I'd like to be able to watch the range of the top object to see when and how it's eating it's young.
@result is a pointer that gives the address of result. The result variable is always at the "top of stack" for any spin program. If you only care about the top of stack for the startup spin program, you can watch the contents of hub location $E with stackpointer := WORD[$E] ....
You could try this code to monitor the stack. It fills the stack from @result + 40 to $7FFF with a pattern, and then checks for the pattern starting from the long at $7FFC. The start of the stack is given by WORD[10]. WORD[$E] is offset from WORD[10] by the space used by the stack variables in the first method plus 8 bytes for a stack frame. Instead of using $7FFF for the end of the stack you could use something more reasonable like WORD[10] + 800, which would allow for 200 longs on the stack. That would speed up the routines a bit.
Dave
Grade my code, this is in the start PUB of my child objects.
then I use this to test the stack space used periodically. Am I (should I be) getting the right answers?
Thanks,
Jim-