Shop OBEX P1 Docs P2 Docs Learn Events
REALLY cool assembly trick — Parallax Forums

REALLY cool assembly trick

CJCJ Posts: 470
edited 2006-05-28 12:17 in Propeller 1
I had been pondering an easier way of loading spin variable addresses into assembly cogs when I thought
"why not preload the data structure at runtime using @s in spin?"

read on for the how to and results

You start with your assembly data, using the "label LONG data" syntax rather than "label RES 1" for your cog variable registers
then you use long[noparse][[/noparse]@dat_address] := @Spin_variable to load the datastructure before launching the cog.
I used the new tv_text_demo as kind of a test bed for the output of the result (from my very first assembly program ever) it is attached below

The result is a few longs saved in cog (may be needed at some point, and in my opinion easier loading of addresses and
data that is needed in-cog)

using long[noparse][[/noparse]@dat_address] := @spin_variable only takes one long and saves having to use cog codespace to load that info
unfortunately it makes the overall program a little larger, and if you want more than one cog running the same assembly program,
you have to set the values again before launch to prevent data clobbering

any comments are greatly apreciated

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?

I've killed a fly with my bare mind.

Comments

  • BeanBean Posts: 8,129
    edited 2006-05-28 04:07
    CJ,
    I was wondering if that was possible, but I didn't have time to check into it. Great minds think alike I guess [noparse];)[/noparse]

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com


    COMING SOON "SD DATA LOGGER" www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • cgraceycgracey Posts: 14,206
    edited 2006-05-28 06:06
    It's even simpler than that. Just say 'label := somevalue'. If·'label' is in the DAT section then the contents of the byte/word/long will be written with 'somevalue'.
    CJ said...
    I had been pondering an easier way of loading spin variable addresses into assembly cogs when I thought
    "why not preload the data structure at runtime using @s in spin?"

    read on for the how to and results

    You start with your assembly data, using the "label LONG data" syntax rather than "label RES 1" for your cog variable registers
    then you use long[noparse][[/noparse]@dat_address] := @Spin_variable to load the datastructure before launching the cog.
    I used the new tv_text_demo as kind of a test bed for the output of the result (from my very first assembly program ever) it is attached below

    The result is a few longs saved in cog (may be needed at some point, and in my opinion easier loading of addresses and
    data that is needed in-cog)

    using long[noparse][[/noparse]@dat_address] := @spin_variable only takes one long and saves having to use cog codespace to load that info
    unfortunately it makes the overall program a little larger, and if you want more than one cog running the same assembly program,
    you have to set the values again before launch to prevent data clobbering

    any comments are greatly apreciated

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • CJCJ Posts: 470
    edited 2006-05-28 12:17
    nice! I didn't know that you could work with it exactly like a variable, syntax-wise. that will save a fair amount of typing

    thanks!
    (comments are good smile.gif)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
Sign In or Register to comment.