Stack space
Lucky
Posts: 98
If the method your launching into a new cog is spin, the cognew command requires a stack pointer, but if its assembly code it doesn't? Why doesn't assembly routines need a stack pointer?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"The man who smiles when things go wrong has thought of someone to blame it on."
-Lucky[size=-1][/size]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"The man who smiles when things go wrong has thought of someone to blame it on."
-Lucky[size=-1][/size]
Comments
The second parameter for cognew with PASM is the value given to the new COG's PAR register.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
May the road rise to meet you; may the sun shine on your back.
May you create something useful, even if it's just a hack.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
He died at the console of hunger and thirst.
Next day he was buried. Face down, nine edge first.
There are 2 lessons to learn:
1. You can't have multiple ret instructions in a subroutine as only the one behind the x_ret label will relly return then.
For example:
call #doSomething
...
doSomething
' check condition
...
IF_C ret
' if not C do something
...
doSomething_ret
ret
This would not work as desired. If you want to exit the subroutine before, you have to jump to the _ret
2. call is self-modifying code. So you should not have empty subroutines as placeholder during development:
' the main code already calls an empty subroutine
call #doSomething
....
doSomething
doSomething_ret
ret
A self-modified instruction can't be executed as next instruction, as the unmodified version is already loaded into the execution pipeline. So, you'd have to put a NOP in between doSomething and doSomething_ret.