Data-endData

Defines a object data structure in the program segment (Flash). Syntax:

  • Data Identifier [at Address constant]1)
    • Data
  • endData
Method (read only)
Name Description Return Type
.ByteValue(offset) Read Byte byte
.WordValue(offset) Read Word word
.IntegerValue(offset) Read Integer integer
.LongValue(offset) Read Long long
.SingleValue(offset) Read Single single
.StringValue(offset,bytes) Read String of explicit length string
.PString(offset) Read Pascal String (Start-Byte is the length) string
.CString(offset) Read C-String (Null terminated) string
.Addr Data Structure Addresse in Flash word
.SizeOf Read Byte size of object byte

* offset: Zero based Byte-Position within the structure

* bytes: Number of Byte to read

Note:

* When accessing Word (16-Bit) Data, then Word_offset = byte_offset * sizeof(Word), e.g. word_offset = byte_offset * 2. * Out of bounds access is possible and is not checked.

Data to fixed address

Setting the data from the specified word address in the flash. A false or erroneous address results in an assembler error message. Take care that we have here is a word address, such as the bootloader address FIRSTBOOTSTART. The byte address would be (word address * 2).

With this functionality, it is possible to store data to a specific, fixed position in the program memory (Flash). If the compiled program is greater than or equal to this address it will overwrite the data. You have to check that is enough free space available.

data storage

The directives for the storage of data within a data object.

  • .db - (byte) 8 Bit values incl. strings
  • .dw - (word) 16 Bit values
  • .dt - (triple) 24 Bit values
  • .dl - (long) 32 Bit values

SuperImposing

' Initialization
[..]
' Main program
dim a as byte
dim s as string
a=table1.ByteValue(4)        ' Read Byte from table1 + 4, Result: 5
s=table1.CString(11)         ' Read C-String, Result: "Hallo"
s=tabelle1.StringValue(11,2) ' Read String of explicit length: Result: "Ha"
s=tabelle1.PString(17)       ' Read Pascal String (First-Byte is the length, 10). Result: "i love you"
Print "&h"+Hex(tabelle1.Addr) ' Display data structure address in Flash
do
loop
 
' Define data structure in Flash
data table1
  .db 1,2,3,4,5
  .dw &h4af1,&hcc55,12345
  .db "Hallo",0
  .db 10,"i love you",0
enddata

Structure

Save data using the structure. Example:

struct eNTRY
  word  	fnAddr
  string	text[12]
endstruct
[..]
data table
  entry { myfunc1, "Menu Nr. 1" }
  entry { myfunc2, "Menu Nr. 2" }
  entry { myfunc3, "Menu Nr. 3" }
enddata
1) at user defined address as of 2013.R1