DATA / WDATA | Example |
Label:
DATA Const0 {, Const1, Const2, ...}
WDATA Const0 {, Const1, Const2, ...}
Function
Creates a table of data values for use with the READ instruction.
Explanation
The DATA and WDATA directives allow the programmer to create a table of
[read only] values for use in the SX/B program. Using DATA or WDATA is a
convenient way to store output patterns and text messages.
DATA is typically used to store byte values, WDATA for word values. If a value greater than 255 is used in a DATA table the value will be stored as two bytes, LSB first. WDATA always stores values as two bytes and, as above, the order is LSB, then MSB.
You must make sure the program does not attempt to execute the DATA or WDATA statements. By convention, DATA and WDATA are placed after the main program loop to prevent the exection of these statements.
CR CON 13 PROGRAM Start Start: LEDs = %00000000 TRIS_LEDs = %00000000 ' make leds outputs Main: idx = 0 TX_Msg: DO READ StartMsg + idx, char IF char = 0 THEN EXIT SEROUT Sio, Baud, char INC idx LOOP ENDIF Show_Count: INC counter IF counter = 10 THEN counter = 0 ENDIF READ SegMap + counter, LEDs PAUSE 1000 GOTO Main ' ------------------------------------------------------------------------- SegMap: ' segments maps ' .gfedcba DATA %00111111 ' 0 DATA %00000110 ' 1 DATA %01011011 ' 2 DATA %01001111 ' 3 DATA %01100110 ' 4 DATA %01101101 ' 5 DATA %01111101 ' 6 DATA %00000111 ' 7 DATA %01111111 ' 8 DATA %01100111 ' 9 StartMsg: DATA "SX/B Really Rocks!", CR, 0 BigTable: WDATA %00000000_00001111 WDATA %00000000_11110000 WDATA %00001111_00000000 WDATA %11110000_00000000
Note: When defining embedded strings as in the example above, the string may be up to 128 characters.
Related instruction: READ