Propeller Manual

Table Of Contents
WORD – Spin Language Reference
Page 230 · Propeller Manual v1.1
DAT
MyData word 640, $AAAA, 5_500 'Word-sized/aligned data
MyList byte word $FF99, word 1_000 'Byte-sized/aligned word data
In this example, the DAT block (bottom of code) places its data in memory as shown in Figure
2-5. The first data element of
MyData is placed at memory address $18. The last data element
of
MyData is placed at memory address $1C, with the first element of MyList immediately
following it at $1E. Note that the starting address ($18) is arbitrary and is likely to change as
the code is modified or the object itself is included in another application.
Data as words
640 $AAAA 5,500 $FF99 1,000
Data as bytes
128 2 $AA
$AA
124
21 $99
$FF
232
3
Figure 2-5: Main Memory Word-Sized Data Structure and Addressing
Near the top of the code, the first executable line of the
MemTest method,
Temp := word[@MyData][1], reads a word-sized value from main memory. It sets local
variable
Temp to $AAAA; the value read from main memory address $1A. The address $1A
was determined by the address of the symbol
MyData ($18) plus word offset 1 (2 bytes). The
following progressive simplification demonstrates this.
word[@MyData][1] ¨ word[$18][1] ¨ word[$18 + (1*2)] ¨ word[$1A]
The next line, word[@MyList][0] := Temp + $0123, writes a word-sized value to main
memory. It sets the value at main memory address $1E to $ABCD. The address $1E was
calculated from the address of the symbol
MyList ($1E) plus word offset 0 (0 bytes).
word[@MyList][0] ¨ word[$1E][0] ¨ word[$1E + (0*2)] ¨ word[$1E]
The value $ABCD was derived from the current value of Temp plus $0123; $AAAA + $0123
equals $ABCD.
Word Address
(Word Offset)
[Word Symbol]
$18
(-6)
$19
(-5)
$1A
(-4)
$1B
(-3)
$1C
(-2)
$1D
(-1)
$1E
(0)
[MyList]
$1F
(1)
$20
(2)
$21
(3)
Byte Address
(Byte Offset)
[Byte Symbol]
$18
(0)
[MyData]
$1A
(1)
$1C
(2)
$1E
(3)
$20
(4)