spin and assembly mix
mctrivia
Posts: 3,772
i am trying to figure out how to read a variable declaired by spin in hub ram modify it on the cog then write back to hub ram.
startDate is an assembly constant. ulDate is not recognized though in assembly so what can I use?
VAR long ulDate,ulTime PUB start cognew(@TimeKeeper,0) DAT org 0 'initialize TimeKeeper wrlong startDate,ulDate
startDate is an assembly constant. ulDate is not recognized though in assembly so what can I use?
Comments
wrlong <destination_address_in_HUB>,<source_address_in_COG>
The point here is that ulDate may be in stack or somewhere else. You have to give a pointer to it to the assembler program. Then it is much better to just define it in a DAT section:
Something like that
The access to variables in DAT section should be done with the long[noparse]/noparse, word[noparse]/noparse and byte[noparse]/noparse ways. The variables defined in VAR sections can be used directly. If I'm not mistaken. The Propeller manual is a very good source of information on the topic.
Btw, wrlong is actually wrlong <cog address>, <hub address> (the reverse of what Ale wrote). It's a little confusing because it violates the expected "destination, source" order. Just remember that all the hub memory ops (rdbyte, wrbyte, rdword, etc.) expect <cog address>, <hub address>.
And, sorry to correct Ale again, but you can access variables in dat sections just as you would an ordinary variable.
If they help, I'll explain what's happening. If they don't, let us never speak of this post again.
changed ptrToulMSec on last line to ptrToUlTime still does not work. Canged read instruction to use this still no luck.
Read seems not to be working. [noparse]:([/noparse]