Propeller Manual

Table Of Contents
Operators – Spin Language Reference
Page 174 · Propeller Manual v1.1
At run time we can access those strings directly, using @Str1, @Str2, and @Str3, but accessing
them indirectly is troublesome because each string is of a different length; making it difficult
to use any of them as a base for indirect address calculations.
The solution might seem to be within reach by simply making another table of the addresses
themselves, as in:
DAT
StrAddr word @Str1, @Str2, @Str3
This creates a table of words, starting at StrAddr, where each word contains the address of a
unique string. Unfortunately, for compile-time constants (like those of the
StrAddr table), the
address returned by
@ is only the compile-time offset address, rather than the run-time
absolute address, of the symbol. To get the true, run-time address, we need to add the
object’s program base address to the symbol’s offset address. That is what the Object
Address Plus Symbol operator does. Example:
REPEAT Idx FROM 0 TO 2
PrintStr(@@StrAddr[Idx])
The above example increments Idx from 0 through 2. The StrAddr[Idx] statement retrieves
the compile-time offset of the string stored in element
Idx of the StrAddr table. The @@
operator in front of the
StrAddr[Idx] statement adds the object’s base address to the
compile-time offset value that was retrieved, resulting in a valid run-time address of the
string. The
PrintStr method, whose code is not shown in this example, can use that address
to process each character of the string.