Propeller Manual

Table Of Contents
2: Spin Language Reference – LONG
Propeller Manual v1.1 · Page 129
Long Variable Declaration (Syntax 1)
In
VAR blocks, syntax 1 of LONG is used to declare global, symbolic variables that are either
long-sized, or are any array of longs. For example:
VAR
long Temp 'Temp is a long (2 words, 4 bytes)
long List[25] 'List is a long array
The above example declares two variables (symbols), Temp and List. Temp is simply a single,
long-sized variable. The line under the
Temp declaration uses the optional Count field to
create an array of 25 long-sized variable elements called
List. Both Temp and List can be
accessed from any
PUB or PRI method within the same object that this VAR block was declared;
they are global to the object. An example of this is below.
PUB SomeMethod
Temp := 25_000_000 'Set Temp to 25,000,000
List[0] := 500_000 'Set first element of List to 500,000
List[1] := 9_000 'Set second element of List to 9,000
List[24] := 60 'Set last element of List to 60
For more information about using LONG in this way, refer to the VAR section’s Variable
Declarations (Syntax 1) on page 210, and keep in mind that
LONG is used for the Size field in
that description.
Long Data Declaration (Syntax 2)
In
DAT blocks, syntax 2 of LONG is used to declare long-aligned, and/or long-sized data that is
compiled as constant values in main memory.
DAT blocks allow this declaration to have an
optional symbol preceding it, which can be used for later reference (see
DAT
T
, page 99). For
example:
DAT
MyData long 640_000, $BB50 'Long-aligned/sized data
MyList byte long $FF995544, long 1_000 'Byte-aligned/long-sized
The above example declares two data symbols, MyData and MyList. MyData points to the start
of long-aligned and long-sized data in main memory.
MyData’s values, in main memory, are
640,000 and $0000BB50, respectively.
MyList uses a special DAT block syntax of LONG that
creates a byte-aligned but long-sized set of data in main memory.
MyList’s values, in main
memory, are $FF995544 and 1,000, respectively. When accessed a byte at a time,
MyList