Stack (SPIN & PASM)
ImmNek
Posts: 29
Hi on the other side ;-D
I can't find a good description of the Propeller's stack handling. I'm coming from the language C and I know about the stack in this context (context-switches and so one). But on the Propeller, it's not clear for me. I know, that there is needed some stack when I call methods. But I don't know any thing, how big the stack size have to be for my code and how I can calculate this. Can somebody explane this to me or give some literatur links, which i didn't found by myself?
Please help me, because I have to understand this completle for a properly design of my apps written in SPIN.
Thanks a lot
Immanuel
I can't find a good description of the Propeller's stack handling. I'm coming from the language C and I know about the stack in this context (context-switches and so one). But on the Propeller, it's not clear for me. I know, that there is needed some stack when I call methods. But I don't know any thing, how big the stack size have to be for my code and how I can calculate this. Can somebody explane this to me or give some literatur links, which i didn't found by myself?
Please help me, because I have to understand this completle for a properly design of my apps written in SPIN.
Thanks a lot
Immanuel
Comments
long Stack[noparse][[/noparse]100]
I am more into pasm than spin, so cannot answer properly, so will leave that for someone else to answer better. However, some users have preset the stack to zeros and after execution have tested the stack (in reverse) to see where it got to. Then add a margin. Hopefully, you can exercise your code to utilise the stack. Unfortunately, there is really no definitive answer -(
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
My cruising website http://www.bluemagic.biz
Thanks a lot for your answer. Unfortunately this is exactly what I know by myself. I hope there is a definitive answer.
@ all:
When there is no definitive answer, then I have to test my code to define the stack size. Then I have the problem, that I don't know how to test my code properly. Can anyone give a method to do this properly?
Thanks a lot, I will try it.
@ all:
Is there no definitive answer? So I will write all my code directly in PASM ;-D
(From: www.rayslogic.com/propeller/FAQ.htm)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again
BTW: I type as I'm thinking, so please don't take any offence at my writing style
However, it should be possible to fill the stack with a known value, say $DEADBEEF, and see how many entries are overwritten.
In regards to PASM, there really isn't a stack, the way calling a function works is that when the call is performed (say routine dothis), the return command indicated by the label dothis_ret is modified to efectively be JMP PC+1 where PC is the index of the call command which invoked the routine. (refer to page 360 of the manual)·So there is no native stack to speak of in PASM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
My cruising website http://www.bluemagic.biz
Thank you for this information. In the manual is now description how to calculate the size of the stack. I hope in a next version there is more stack related stuff. There are only some very simple examples and the stack size is always 9 longs and this are VERY simple examples.
@ Paul Baker:
I know, that in assambly there is't a stack. This wouldn't make any sense, because you have to move every parameter or other registers by yourselfe and there aren't any functions or methods like in a high-level language or an interpreted language. That's exactly why I joked and said I will write all my code in PASM, because then I don't have any problems related to the stack.
Thanks a lot for the link to the tool created by Phil, I will have a look on it.
@ Andrew E Mileski:
Nice idea to overview the stack pointer. I just have to find out it's address and set it to a value and look up for changes.
@ all:
Thank you all for your information. I see, there is no easy way to calculate the stack size for my SPIN-code, but there are some ways and thats the main. So, now I have to do the rest by myself.