A .data directive contains an optional data label and the body which defines the actual data. A data label shall be used if the data is to be accessed by the code.
DataDecl ::= |
---|
[ DataLabel '=' ] DdBody |
The body consists either of one data item or a list of data items in braces. A list of data items is similar to an array.
DdBody ::= |
---|
DdItem |
A list of items consists of any number of items:
DdItemList ::= |
---|
DdItem [ ',' DdItemList ] |
The list can be used to declare multiple data items associated with one label. The items will be laid out in the order declared. The first data item is accessible directly through the label. To access the other items, pointer arithmetic is used, adding the size of each data item to get to the next one in the list. The use of pointer arithmetic will make the application non-verifiable. (Each data item shall have a DataLabel if it is to be referenced afterwards; missing a DataLabel is useful in order to insert alignment padding between data items)
A data item declares the type of the data and provides the data in parentheses. If a list of data items contains items of the same type and initial value, the grammar below can be used as a short cut for some of the types: the number of times the item shall be replicated is put in brackets after the declaration.
DdItem ::= | Description |
---|---|
'&' '( Id ')' |
Address of label |
| bytearray '(' Bytes ')' |
Array of bytes |
| char '*' '(' QSTRING ')' |
Array of (Unicode) characters |
| float32 [ '(' Float64 ')' ] [ '[' Int32 ']' ] |
32-bit floating-point number, can be replicated |
| float64 [ '(' Float64 ')' ] [ '[' Int32 ']' ] |
64-bit floating-point number, can be replicated |
| int8 [ '(' Int32 ')' ] [ '[' Int32 ']' ] |
8-bit integer, can be replicated |
| int16 [ '(' Int32 ')' ] [ '[' Int32 ']' ] |
16-bit integer, can be replicated |
| int32 [ '(' Int32 ')' ] [ '[' Int32 ']' ] |
32-bit integer, can be replicated |
| int64 [ '(' Int64 ')' ] [ '[' Int32 ']' ] |
64-bit integer, can be replicated |
[Example: The following declares a 32-bit signed integer with value 123:
.data theInt = int32(123)
The following declares 10 replications of an 8-bit unsigned integer with value 3:
.data theBytes = int8 (3) [10]
end example]