# TAP ( TELOCATOR Alphanumeric Protocol) checksum calculation

ajish.raju
chief evangelist of favantePosts:

**185**
I am trying to convert a BASIC program to AMX for a checksum calculation. Let me know if you have done similarly. I have posted my code block and the protocol pdf for reference. Below is the BASIC program sample.

REM - This sample BASIC program converts the checksum value "sum" into the

REM - three characters which are sent as part of the TAP protocol. The variables

REM - d1, d2 and d3 contain the three digits which are to be added to the

REM - transmitted data block. "INT" is the integer function which returns the

REM - integer portion of a number. This function is required if the variables

REM - are floating point numbers. If they are declared as integers then the INT

REM - function is not required. This BASIC program may easily be converted to

REM - other programming languages.

REM -

sum = 379

REM -

REM - Following the checksum example in the TAP Specification Document:

REM - <STX> 1 2 3 <CR> A B C <CR> <ETX> the checksum value is 379.

REM - The following code will create the three characters to be transmitted

REM - in order to represent this checksum.

REM -

d3 = 48 + sum - INT(sum / 16) * 16

sum = INT(sum / 16)

d2 = 48 + sum - INT(sum / 16) * 16

sum = INT(sum / 16)

d1 = 48 + sum - INT(sum / 16) * 16

REM -

REM - Print the three character checksum in decimal and ASCII

REM -

PRINT "d1="; d1, "d2="; d2, "d3="; d3

PRINT "d1$="; CHR$(d1), "d2$="; CHR$(d2), "d3$="; CHR$(d3)

REM - This sample BASIC program converts the checksum value "sum" into the

REM - three characters which are sent as part of the TAP protocol. The variables

REM - d1, d2 and d3 contain the three digits which are to be added to the

REM - transmitted data block. "INT" is the integer function which returns the

REM - integer portion of a number. This function is required if the variables

REM - are floating point numbers. If they are declared as integers then the INT

REM - function is not required. This BASIC program may easily be converted to

REM - other programming languages.

REM -

sum = 379

REM -

REM - Following the checksum example in the TAP Specification Document:

REM - <STX> 1 2 3 <CR> A B C <CR> <ETX> the checksum value is 379.

REM - The following code will create the three characters to be transmitted

REM - in order to represent this checksum.

REM -

d3 = 48 + sum - INT(sum / 16) * 16

sum = INT(sum / 16)

d2 = 48 + sum - INT(sum / 16) * 16

sum = INT(sum / 16)

d1 = 48 + sum - INT(sum / 16) * 16

REM -

REM - Print the three character checksum in decimal and ASCII

REM -

PRINT "d1="; d1, "d2="; d2, "d3="; d3

PRINT "d1$="; CHR$(d1), "d2$="; CHR$(d2), "d3$="; CHR$(d3)

0

## Comments

94185185