reusing names for local variables in asm
pems
Posts: 70
Hi
I need some guidance and/or examples. I've read bunch of scattered docs, and tried searching - found nothing on this
I would also appreciate links to relevant discussions
basically the project is to load different asm chunks into cogs, then have those cogs talking to each other over the hub memory
my questions are following:
- what's the best/most elegant way to organize the asm code for diff cogs providing it's all in one .spin file (to keep it simple) ?
i currently do it this way:
VAR
<hub ram variables through which cogs talk>
PUB
<minimal code to launch cogs, passing appropriate ASM locations in DAT section of the same .spin file and a parameter>
DAT
'asm code organized as following:
org 0
ASM label for the cog#0 entry point
<cog#0 code>
<cog#0 initialized vars>
<cog#0 uninitialized vars (res)>
org 0
ASM label for the cog #1 entry point
<cog#1 code>
etc. following the above pattern
this works ok, but one grief i have is i seem to be forced to have all variable names unique within the whole DAT section. So if i want to use say "i" local var name in two diff cogs, i have to do something like i_1 or i_2 which is very inconvenient (or as a more concrete example, rxt, txt, rxb, etc local variables for using FullDuplexSerial object from several cogs)
Is there a nicer way to organize the code so this local variable name sharing wouldn't be an issue?
Thanks
I need some guidance and/or examples. I've read bunch of scattered docs, and tried searching - found nothing on this
I would also appreciate links to relevant discussions
basically the project is to load different asm chunks into cogs, then have those cogs talking to each other over the hub memory
my questions are following:
- what's the best/most elegant way to organize the asm code for diff cogs providing it's all in one .spin file (to keep it simple) ?
i currently do it this way:
VAR
<hub ram variables through which cogs talk>
PUB
<minimal code to launch cogs, passing appropriate ASM locations in DAT section of the same .spin file and a parameter>
DAT
'asm code organized as following:
org 0
ASM label for the cog#0 entry point
<cog#0 code>
<cog#0 initialized vars>
<cog#0 uninitialized vars (res)>
org 0
ASM label for the cog #1 entry point
<cog#1 code>
etc. following the above pattern
this works ok, but one grief i have is i seem to be forced to have all variable names unique within the whole DAT section. So if i want to use say "i" local var name in two diff cogs, i have to do something like i_1 or i_2 which is very inconvenient (or as a more concrete example, rxt, txt, rxb, etc local variables for using FullDuplexSerial object from several cogs)
Is there a nicer way to organize the code so this local variable name sharing wouldn't be an issue?
Thanks
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
i will try this. Clearly i will need all labels in one cog program to start with : , that's gonna be a lot of :'s