Propeller Manual

Table Of Contents
DAT – Spin Language Reference
Declaring Data(Syntax 1)
Data is declared with a specific alignment and size (
BYTE, WORD, or LONG) to indicate how it
should be stored in memory. The location where data is actually stored depends on the
structure of the object and the application it is compiled into since data is included as part of
the compiled code.
For example:
DAT
byte 64, "A", "String", 0
word $FFC2, 75000
long $44332211, 32
The first thing on line two of this example, BYTE, indicates the data following it should be
byte-aligned and byte-sized. At compile time, the data following
BYTE, 64, “A”, etc., is stored
in program memory a byte at a time starting at the next available location. Line three
specifies word-aligned and word-sized data. Its data,
$FFC2 and 75000, will begin at the next
word boundary position following the data that appeared before it; with any unused bytes
from the previous data filled with zeros to pad up to the next word boundary. The fourth line
specifies long-aligned and long-sized data; its data will be stored at the next long boundary
following the word-aligned data that appeared before it, with zero-padded words leading up
to that boundary. Table 2-8 shows what this looks like in memory (shown in hexadecimal).
Table 2-8: Example Data in Memory
L 0 1 2 3 4 5
W 0 1 2 3 4 5 6 7 8 9 10 11
B 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
D 40 41 53 74 72 69 6E 67 00 00 C2 FF F8 24 00 00 11 22 33 44 20 00 00 00
L = longs, W = words, B = bytes, D = data
The first nine bytes (0 – 8) are the byte data from line one; $40 = 64 (decimal), $41 = “A”,
$53 = “S”, etc. Byte 9 is padded with zero to align the first word of word-aligned data,
$FFC2, at byte 10. Bytes 10 and 11 (word 5) contain the first word-sized value, $FFC2,
stored in low-byte-first format as $C2 and $FF. Bytes 12 and 13 (word 6) is the lowest word
of 75000; more on this later. Bytes 14 and 15 (word 7) are zero padded to align the first long
of long-aligned data, $44332211. Bytes 16 through 19 (long 5) contain that value in low-
byte-first format. Finally, bytes 20 through 23 (long 6) contains the second long of data, 32,
in low-byte-first format.
Page 100 · Propeller Manual v1.1