Propeller (inglés)

Page 229

2: Spin Language Reference – WORD Word Data Declaration (Syntax 2) In DAT blocks, syntax 2 of WORD is used to declare word-aligned, and/or word-sized data that is compiled as constant values in main memory. DAT blocks allow this declaration to have an optional symbol preceding it, which can be used for later reference. See DAT, page 99. For example: T

DAT MyData MyList

word byte

640, $AAAA, 5_500 word $FF99, word 1_000

'Word-aligned/word-sized data 'Byte-aligned/word-sized data

The above example declares two data symbols, MyData and MyList. MyData points to the start of word-aligned and word-sized data in main memory. MyData’s values, in main memory, are 640, $AAAA and 5,500, respectively. MyList uses a special DAT block syntax of WORD that creates a byte-aligned but word-sized set of data in main memory. MyList’s values, in main memory, are $FF99 and 1,000, respectively. When accessed a byte at a time, MyList contains $99, $FF, 232 and 3 since the data is stored in little-endian format. This data is compiled into the object and resulting application as part of the executable code section and may be accessed using the read/write form, syntax 3, of WORD (see below). For more information about using WORD in this way, refer to the DAT section’s Declaring Data(Syntax 1) on page 100 and keep in mind that WORD is used for the Size field in that description. Data items may be repeated by using the optional Count field. For example:

DAT MyData

word

640, $AAAA[4], 5_500

The above example declares a word-aligned, word-sized data table, called MyData, consisting of the following six values: 640, $AAAA, $AAAA, $AAAA, $AAAA, 5500. There were four occurrences of $AAAA due to the [4] in the declaration immediately after it. Reading/Writing Words of Main Memory (Syntax 3) In PUB and PRI blocks, syntax 3 of WORD is used to read or write word-sized values of main memory. This is done by writing expressions that refer to main memory using the form: word[BaseAddress][Offset]. Here’s an example.

PUB MemTest | Temp Temp := word[@MyData][1] word[@MyList][0] := Temp + $0123

'Read word value 'Write word value Propeller Manual v1.1 · Page 229


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.