Propeller Manual

Table Of Contents
2: Spin Language Reference – Operators
Propeller Manual v1.1 · Page 173
Symbol Address ‘@
The Symbol Address operator returns the address of the symbol following it. Symbol
Address can be used in variable and integer constant expressions, but not in floating-point
constant expressions. Example:
BYTE[@Str] := "A"
In the above example, the Symbol Address operator returns the address of the Str symbol,
which is then used by the
BYTE memory array reference to store the character "A" at that
address.
Symbol Address is often used to pass the address of strings and data structures, defined in a
DAT block, to methods that operate on them. T
It is important to note that this is a special operator that behaves differently in variable
expressions than it does in constant expressions. At run time, like our example above shows,
it returns the absolute address of the symbol following it. This run-time, absolute address
consists of the object’s program base address plus the symbol’s offset address.
In constant expressions, it only returns the symbol’s offset within the object. It cannot return
the absolute address, effective at run time, because that address changes depending on the
object’s actual address at run time. To properly use the Symbol Address in a constant, such
as a table of data, see the Object Address Plus Symbol operator, below.
Object Address Plus Symbol ‘
@@
The Object Address Plus Symbol operator returns the value of the symbol following it plus
the current object’s program base address. Object Address Plus Symbol can only be used in
variable expressions.
This operator is useful when creating a table of offset addresses, then at run time, using those
offsets to reference the absolute run-time addresses they represent. For example, a
DAT block
may contain a number of strings to which you want both direct and indirect access. Here’s an
example
T
DAT block containing strings.
DAT
Str1 byte "Hello.", 0
Str2 byte "This is an example", 0
Str3 byte "of strings in a DAT block.",0