REALLY cool assembly trick
CJ
Posts: 470
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.
"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
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
·
Chip Gracey
Parallax, Inc.
thanks!
(comments are good )
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.