|

Chicago-Soft
ATTN: TSO Times
One Maple Street
Hanover, NH 03755
(603) 643-4002
information
@tsotimes.com

|
|
Quick
Tip - Calculating CHECKSUM Values
by Jim Leone
If you have a need
to use the CHECKSUM control card for AMASPZAP, but are not too sure
how
it works or comfortable
with HEX calculations, then the REXX exec CHECKSUM will be useful.
It works by adding
all the HEX values on the VER/REP control statements and putting the
result
on a
Checksum statement following the last VER/REP card.
The tricky part about
using the Checksum parameter is that all HEX characters are strung
together
and
added eight characters to the next eight characters, dropping the
first position if the result in the answer is nine characters long. This
process is repeated(the previous result added to the next eight characters)
until all characters have been added together. If the last segment to
be added is only four characters long,
those four make up the high order
positions and the remaining four are padded with zeros. The final result
is also trimmed down to eight characters if necessary. As you can see,
this is a tedious process if done
manually, especially for long ZAPs.
You execute the REXX
exec with two arguments indicating the first line number of the REP/VER
statement
and last line number of the REP/VER statement to be added.
The Checksum statement
must follow this last REP/VER card. Also you must not code the HEX
values
with
commas separating the bytes. You can code the commas initially for
your own readability in checking your
entries, but remember to remove
them before executing the REXX exec. The REXX exec code follows.
Download this Exec in
text format (WI96QT1-CHKS.TXT)
/* REXX EXEC ********************************************** */
/* TRACE ALL */
/************************************************************/
/*REXX EXEC: CHECKSUM */
/*WRITTEN BY: JIM LEONE DATE: 8/22/95 */
/*PURPOSE: TO CALCULATE THE CHECKSUM VALUE FOR ZAPS */
/*USAGE: EDIT MACRO COMMAND IN EDIT MODE, */
/* COMMAND: CHECKSUM BEG END */
/* BEG = FIRST REP/VER STATEMENT */
/* END = LAST REP/VER STATEMENT */
/* FOLLOW THE LAST REP/VER STATEMENT WITH A CHECKSUM STATEMENT AND THE MACRO
WILL PUT THE CALCULATION ON THAT STATEMENT */
/* */
/*SPECIAL NOTE: HEX CHARACTERS MUST NOT BE SEPARATED BY COMMAS!! */
/*SPECIAL NOTE: YOU MUST REMOVE THE COMMAS FOR THE MACRO TO WORK! */
/************************************************************/
NUMERIC DIGITS 15
ADDRESS "ISREDIT" "MACRO (BEGL,ENDL)"
LOOPCTRL = ENDL - BEGL + 1
ALLVALUES = ‘’
DO LOOPCTRL
"ISREDIT (DATAL) = LINE" BEGL
PARSE VAR DATAL OPER BASE HEXES .
ALLVALUES = ALLVALUES || BASE || HEXES
/* SAY "ALLVALUES = "ALLVALUES */
BEGL = BEGL + 1
END
DONE =’NO’
HEXTOT = 0
DO UNTIL DONE = ‘YES’
HEXLENGTH = LENGTH(ALLVALUES)
IF HEXLENGTH < 16
THEN
DO
DONE = ‘YES’
CALL LASTONE
HEXTOTAL = "‘CHECKSUM " || HEXTOT || "‘ .HERE .HERE"
"ISREDIT RESET LABEL"
"ISREDIT LABEL "ENDL + 1" = .HERE"
ADDRESS "ISREDIT "
"CHANGE ‘CHECKSUM’ " HEXTOTAL
EXIT
END
ELSE
DO /* DO SUB1 */
FIRST8 = SUBSTR(ALLVALUES,1,8)
NEXT8 = SUBSTR(ALLVALUES,9,8)
DEC1 = X2D(FIRST8)
DEC2 = X2D(NEXT8)
DECNUM = DEC1 + DEC2
HEXSUB = D2X(DECNUM)
IF LENGTH(HEXSUB) > 8
THEN HEXSUB = SUBSTR(HEXSUB,2,8)
DECTOT = X2D(HEXTOT) + X2D(HEXSUB)
HEXTOT = D2X(DECTOT)
IF LENGTH(HEXTOT) > 8
THEN HEXTOT = SUBSTR(HEXTOT,2,8)
ALLVALUES = SUBSTR(ALLVALUES,17)
END /* DO SUB1 */
END /* MAIN DO */
HEXTOTAL = "‘CHECKSUM " || HEXTOT || "‘ .HERE .HERE"
ADDRESS "ISREDIT "
"ISREDIT RESET LABEL"
"ISREDIT LABEL "ENDL + 1" = .HERE"
"CHANGE ‘CHECKSUM’ " HEXTOTAL
EXIT
LASTONE:
IF HEXLENGTH = 4
THEN
CALL LAST4
IF HEXLENGTH = 8
THEN
CALL LAST8
IF HEXLENGTH = 12
THEN
CALL LAST12
RETURN ‘’
LAST4:
DO
FIRST8 = ALLVALUES
FIRST8 = FIRST8 || ‘0000’
DEC1 = X2D(FIRST8)
DECT1 = X2D(HEXTOT)
DECNUM = DEC1 + DECT1
HEXTOT = D2X(DECNUM)
IF LENGTH(HEXTOT) > 8
THEN HEXTOT = SUBSTR(HEXTOT,2,8)
END
RETURN ‘’
LAST8:
DO
FIRST8 = ALLVALUES
DEC1 = X2D(FIRST8)
DECT1 = X2D(HEXTOT)
DECNUM = DEC1 + DECT1
HEXTOT = D2X(DECNUM)
IF LENGTH(HEXTOT) > 8
THEN HEXTOT = SUBSTR(HEXTOT,2,8)
END
RETURN ‘’
LAST12:
DO
FIRST8 = SUBSTR(ALLVALUES,1,8)
NEXT8 = SUBSTR(ALLVALUES,9,4)
NEXT8 = NEXT8 || ‘0000’
DEC1 = X2D(FIRST8)
DEC2 = X2D(NEXT8)
DECNUM = DEC1 + DEC2
HEXSUB = D2X(DECNUM)
IF LENGTH(HEXSUB) > 8
THEN HEXSUB = SUBSTR(HEXSUB,2,8)
DECT1 = X2D(HEXTOT)
DECT2 = X2D(HEXSUB)
DECTOT = DECT1 + DECT2
HEXTOT = D2X(DECTOT)
IF LENGTH(HEXTOT) > 8
THEN HEXTOT = SUBSTR(HEXTOT,2,8)
END
RETURN ‘’
EXIT
Jim Leone is a
systems programmer for Systems & Computer Technology Corp. of Malvern,
PA, working at Temple University, Philadelphia, PA.
|
 |

|