Propeller Manual

Table Of Contents
DAT – Spin Language Reference
This example creates a data table called MyData that consists of bytes $FF, 25 and %1010.
The public method,
GetData, reads the first byte of MyData from main memory and stores it in
its local variable,
Temp.
You can also use the
BYTE, WORD, and LONG declarations to read main memory locations. For
example:
DAT
MyData byte $FF, 25, %1010
PUB GetData | Temp
Temp := BYTE[@MyData][0] 'Get first byte of data table
This example is similar to the previous one except that it uses the
BYTE declaration to read the
value stored at the address of
MyData. Refer to BYTE, page 51; WORD, page 227; and LONG, page
128, for more information on reading and writing main memory.
Declaring Repeating Data (Syntax 1)
Data items may be repeated by using the optional Count field. For example:
DAT
MyData byte 64, $AA[8], 55
The above example declares a byte-aligned, byte-sized data table, called MyData, consisting of
the following ten values: 64, $AA, $AA, $AA, $AA, $AA, $AA, $AA, $AA, 55. There were
eight occurrences of $AA due to the
[8] in the declaration immediately after it.
Writing Propeller Assembly Code (Syntax 2)
In addition to numeric and string data, the
DAT block is also used for Propeller Assembly
code. The following example toggles pin 0 every ¼ second.
DAT
org 0 'Reset assembly pointer
Toggle rdlong Delay, #0 'Get clock frequency
shr Delay, #2 'Divide by 4
mov Time, cnt 'Get current time
add Time, Delay 'Adjust by 1/4 second
mov dira, #1 'set pin 0 to output
Loop waitcnt Time, Delay 'Wait for 1/4 second
xor outa, #1 'toggle pin
jmp #Loop 'loop back
Page 102 · Propeller Manual v1.1