pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
checksum
input,output
uINT:variable
the initial value (“seed” value) of the checksum. When $CHECKSUM completes, checksum
holds the final checksum. checksum must be an INT variable. It cannot be a STRING,
UNSIGNED, or USE variable or a bit field.
bufferaddr
input
EXTADDR:value
the address of the first 16-bit word to include in the checksum.
wordcount
input
uINT:value
the number of 16-bit words to include in the checksum.
$CHECKSUM accumulates the checksum by performing an exclusive-or operation on the
accumulated checksum and wordcount successive 16-bit words, starting at bufferaddr.
When $CHECKSUM completes, checksum holds the accumulated checksum and bufferaddr
is unchanged.
Example 240 $CHECKSUM Routine
LITERAL buffer_len = 100;
INT c_sum_val;
INT .EXT buffer1 [ 0:buffer_len - 1 ];
INT .EXT buffer2 [ 0:buffer_len - 1 ];
buffer1 ':=' [%H0123, %H4567, %H89AB];
c_sum_val:= 3;
$CHECKSUM(c_sum_val, @buffer1, buffer_len);
! Value of c_sum_val is now %HCDEF
! Checksum buffer2 in same checksum word as buffer1
$CHECKSUM(c_sum_val, @buffer2, buffer_len);
! c_sum_val now has the combined checksum of buffer1 & buffer2
$COMP
$COMP returns the one’s complement of its argument.
298 Built-In Routines