Syntax
CHECKSUM, TM Val_S, Val_E, VARD
|
Checksum between addresses Val_S and Val_E
|
CHECKSUM, TM VAR_S, VAR_E, VARD
|
Checksum between addresses set in variables VAR_S and VAR_E
|
Operands | Val_S: 16-bit unsigned integer value representing the checksum start address |
Val_E: 16-bit unsigned integer value representing the checksum end address
VAR_S: 16-bit variable containing the checksum start address
VAR_E: 16-bit variable containing the checksum end address
VARD: 16-bit variable containing the checksum result
TM: Memory type (see TypeMem table below)
Binary code
Description | Computes the sum module 65536 of all the memory locations between a start address and an end address. The start address and the end address may be specified as 16-bit unsigned immediate values or via 2 16-bit TML variables. The checksum result is saved in a 16-bit destination variable. The memory location can be of 3 types: RAM for data (dm), RAM for TML programs (pm), EEPROM SPI-connected for TML programs (spi). |
Example
// compute checksum between EEPROM addresses 0x5000 and 0x5007
int user_var;
....
CHECKSUM, spi 0x5000, 0x5007, user_var; // user_var = checksum value
Before instruction
|
|
After instruction
|
user_var
|
x
|
|
user_var
|
0xD467
|
EEPROM start address 0x5000
|
0xB004
|
|
EEPROM start address 0x5000
|
0xB004
|
EEPROM address 0x5001
|
0x0FF1
|
|
EEPROM address 0x5001
|
0x0FF1
|
EEPROM address 0x5002
|
0x0366
|
|
EEPROM address 0x5002
|
0x0366
|
EEPROM address 0x5003
|
0x0404
|
|
EEPROM address 0x5003
|
0x0404
|
EEPROM address 0x5004
|
0x0C09
|
|
EEPROM address 0x5004
|
0x0C09
|
EEPROM address 0x5005
|
0x0010
|
|
EEPROM address 0x5005
|
0x0010
|
EEPROM address 0x5006
|
0x00E7
|
|
EEPROM address 0x5006
|
0x00E7
|
EEPROM address 0x5007
|
0x0008
|
|
EEPROM address 0x5007
|
0x0008
|
|