Where is the stack?
Kye
Posts: 2,200
Okay, so, I was thinking about how to implement a dynamic memory object of my own that would manage a heap growing from the bottom of the memory up when I realized that I don't know what·spin is doing with that empty memory.
That said, where is the call stack that is referenced in spin documentation? Does it float around in that empty memory after variable space? And is you how do I know how big it will grow?
Because if I want to make a heap I need to know what the call stack is doing.·Is their any documentation on this anywhere?
Thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
That said, where is the call stack that is referenced in spin documentation? Does it float around in that empty memory after variable space? And is you how do I know how big it will grow?
Because if I want to make a heap I need to know what the call stack is doing.·Is their any documentation on this anywhere?
Thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Comments
The SP isn't exposed to Spin programs but there is a trick to peek inside a running Cog from Spin to see what the SP contains. Some details are towards the end of this thread and there may be more specific details in other threads, and threads on Zero-Footprint Debugging holds details of a lot of the trickery ...
http://forums.parallax.com/showthread.php?p=739430
It's all quite complicated, and it's been a while since I've used the Prop at that level of tinkering.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
That's for the main program, top-level object. Sub-objects will have their stack in whatever array was used for them in CogNew/CogInit. When their SP gets too large it will start writing on other data.
I experienced out-of-stack space (up to yesterday, actually) while trying to solve a serial comms problem. It's not nice: the propeller "lost-it" and transmitted a lot of junk through the serial port and then stopped (at least transmitting). Would do the same thing each time I reset the processor. Increasing the stack variable (_STACK) until the problem disappeared. Not very scientific approach but it worked. Over nesting was part of the problem.
Cheers,
4Alex