Propeller Manual

Table Of Contents
BYTE – Spin Language Reference
Page 56 · Propeller Manual v1.1
LongVar.byte[2] := 75 'Set third byte of LongVar to 75
LongVar.byte[3] := 100 'Set fourth byte of LongVar to 100
This example accesses the byte-sized components of both WordVar and LongVar, individually.
The comments indicate what each line is doing. At the end of the
Main method, WordVar will
equal 25,600 and
LongVar will equal 1,682,649,625.
The same techniques can be used to reference byte-sized components of word-sized or long-
sized data symbols.
PUB Main | Temp
Temp := MyData.byte[0] 'Read low byte of MyData word 0
Temp := MyData.byte[1] 'Read high byte of MyData word 0
MyList.byte[3] := $12 'Write high byte of MyList long 0
MyList.byte[4] := $FF 'Write low byte of MyList long 1
DAT
MyData word $ABCD, $9988 'Word-sized/aligned data
MyList long $FF998877, $EEEE 'Long-sized/aligned data
The first and second executable lines of Main read the values $CD and $AB, respectively,
from
MyData. The third line writes $12 to the high byte of the long in element 0 of MyList,
resulting in a value of $12998877. The fourth line writes $FF to the byte at index 4 in
MyList
(the low byte of the long in element 1), resulting in a value of $EEFF.