Propeller Manual

Table Of Contents
2: Spin Language Reference – DAT
You may have noticed that the value 75000 was specified as a word-sized one. The number
75000 in hexadecimal is $124F8, but since that’s larger than a word, only the lowest word
($24F8) of the value was stored. This resulted in word 6 (bytes 12 and 13) containing $F8
and $24, and word 7 (bytes 14 and 15) containing $00 and $00 due to the padding for the
following long-aligned values.
This phenomenon, whether or not it is intentional, occurs for byte-aligned/byte-sized data as
well, for example:
DAT
byte $FFAA, $BB995511
...results in only the low bytes of each value, $AA and $11 being stored in consecutive
locations.
Occasionally, however, it is desirable to store an entire large value as smaller elemental units
that are not necessarily aligned according to the size of the value itself. To do this, specify
the value’s size just before the value itself.
DAT
byte word $FFAA, long $BB995511
This example specifies byte-aligned data, but a word-sized value followed by a long-sized
value. The result is that the memory contains $AA and $FF, consecutively, and following it,
$11, $55, $99 and $BB.
If we modify line three of the first example above as follows:
word $FFC2, long 75000
...then we’d end up with $F8, $24, $01, and $00 occupying bytes 12 through 15. Byte 15 is
the upper byte of the value and it just happens to be immediately left of the next long
boundary so no additional zero-padded bytes are needed for the next long-aligned data.
Optionally, the Symbol field of syntax 1 can be included to “name” the data. This makes
referencing the data from a
PUB or PRI block easy. For example:
DAT
MyData byte $FF, 25, %1010
PUB GetData | Temp
Temp := MyData[0] 'Get first byte of data table
Propeller Manual v1.1 · Page 101