pointer to DAT as DAT
PaulForgey
Posts: 25
EDIT: late night stupidity. I was assuming wrong about DAT locations vs objects, as there is still an object offset. I was pointed to the _operator_ section of the docs which explains this (not the DAT section).
I wish to have addresses of other DAT locations as DAT constants. Because this section is not relocated (it isn't object data), all this is known at compile time and should be fine. So if I try something like:
This actually does not work as expected. In the specific case of my test program, @label is $3c, and LONG[@label] is $1234567 as expected. But pointer[0] is $4c, not $3c. Why is this? Is what I am trying to do possible? If not, why not?
I wish to have addresses of other DAT locations as DAT constants. Because this section is not relocated (it isn't object data), all this is known at compile time and should be fine. So if I try something like:
DAT label LONG $1234567 pointer LONG @label ' or WORD to be compact, as pointers never exceed 16 bits
This actually does not work as expected. In the specific case of my test program, @label is $3c, and LONG[@label] is $1234567 as expected. But pointer[0] is $4c, not $3c. Why is this? Is what I am trying to do possible? If not, why not?
Comments
The BST Propeller IDE added a "@@@" operator to do what you want.
I think this is now supported in OpenSpin hence in the Propeller IDE.
Sadly not in the Parallax Propeller Tool.
To print a day name to the terminal you might do this:
Wow, thank you.
I have been wondering for years what possible use @@ is!
It does not help if you are writing in PASM though.
day[] contains the memory locations of 7 zero-terminated ascii strings.
@@ you are telling term.str to start sending bytes from the address stored in a array[] of addresses.
An alternative is to adjust the offsets programmatically in the Spin start-methode: Then you can access the array without @@: and the pointers are also correct for assembly code.
With the way I have done the offset adjust, it works also if you call the startmethode more than once. For example when a Reset occures.
Andy
This code actually needs to be able to run in multiple cores, so adjusting the values at runtime isn't a good option for me, but that's a good trick to know.