Shop OBEX P1 Docs P2 Docs Learn Events
reusing names for local variables in asm — Parallax Forums

reusing names for local variables in asm

pemspems Posts: 70
edited 2008-09-22 00:01 in Propeller 1
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

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-09-21 19:25
    Have you seen local labels? They are labels with : in front of them. Thier scope exists between 2 non-local labels (say the entry labels for each cog)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • pemspems Posts: 70
    edited 2008-09-22 00:01
    Thanks for taking time to reply Paul

    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
Sign In or Register to comment.