Propeller Manual

Table Of Contents
2: Spin Language Reference – LONG
Data as longs
640,000 $BB50 $FF995544 1,000
Long Address
(Long Offset)
[Long Symbol]
$18
(0)
[MyData]
$24
(3)
$20
(2)
$1C
(1)
Data as bytes
0 196
9 0 $50 $BB
$00
$00
$44
$55
$99
$FF 232 3 0 0
Figure 2-2: Main Memory Long-Sized Data Structure and Addressing
$18
(-8)
$19
(-7)
$1A
(-6)
$1B
(-5)
$1C
(-4)
$1D
(-3)
$1F
(-1)
$20
(0)
[MyList]
$21
(1)
$22
(2)
$23
(3)
$24
(4)
$25
(5)
$26
(6)
$27
(7)
$1E
(-2)
Byte Address
(Byte Offset)
[Byte Symbol]
Near the top of the code, the first executable line of the
MemTest method,
Temp := long[@MyData][1], reads a long-sized value from main memory. It sets local
variable
Temp to $BB50; the value read from main memory address $1C. The address $1C
was determined by the address of the symbol
MyData ($18) plus long offset 1 (4 bytes). The
following progressive simplification demonstrates this.
long[@MyData][1] ¨ long[$18][1] ¨ long[$18 + (1*4)] ¨ long[$1C]
The next line, long[@MyList][0] := Temp + $01234567, writes a long-sized value to main
memory. It sets the value at main memory address $20 to $012400BC. The address $20 was
calculated from the address of the symbol MyList ($20) plus long offset 0 (0 bytes).
long[@MyList][0] ¨ long[$20][0] ¨ long[$20 + (0*4)] ¨ long[$20]
The value $012400BC was derived from the current value of Temp plus $012400BC; $BB50 +
$01234567 equals $012400BC.
Addressing Main Memory
As Figure 2-2 suggests, main memory is really just a set of contiguous bytes (see “data as
bytes” row) that can also be read as longs (4-byte sets) when done properly. In fact, the
above example shows that even the addresses are calculated in terms of bytes. This concept
is a consistent theme for any commands that use addresses.
Main memory is ultimately addressed in terms of bytes regardless of the size of value you are
accessing; byte, word, or long. This is advantageous when thinking about how bytes, words,
Propeller Manual v1.1 · Page 131