Checksum program for slc basic module – Rockwell Automation 2706-F11J_F11JC_F21J_F21JC DL50 INSTALLATION MANUAL User Manual

Page 121

Advertising
background image

Appendix F

Checksum Calculations

F–2

The following subroutine calculates the checksum of a message for a
1746-BAS SLC BASIC module. The message text is stored in string $(0) and
the duplex control fields are in the variables F1, F3, F4, F6, F62, and F63.

5400

REM ** CHECKSUM CALCULATION FOR 1746-BAS

5401

REM ** WHERE MESSAGE TEXT IS IN STRING $(0)

5402

REM ** AND F1, F3, F4, F6, F62, AND F63

5403

REM ** ARE THE DUPLEX FIELD VALUES

5410

TCSUM=0:CHD=0:CSUM=0

5420

PUSH 0

:REM GET LENGTH $(0)

5430

CALL 68

5440 POP

SL

5450

BAD=0

5460

IF SL=0 THEN GOTO 5500

5470

FOR POSIT = 1 TO SL STEP 1

5480

TCSUM=TCSUM+ASC($(0),POSIT)

5490

NEXT POSIT

5500

CSUM=F1+TCSUM+F3+F4

5510

CSUM=CSUM+13+F6+F62+F63

5520

CHH=INT(CSUM/256)

5530

CHL=CSUM-(256*CHH)

5540

IF CHL=13 .OR. CHL=18 THEN CHD=1:BAD=1

5550

IF CHH=13 .OR. CHH=18 THEN CHD=CHD+127:BAD=1

5560

IF BAD=1 THEN GOTO 5420

5570

RETURN

5580

END

Checksum Program for
SLC BASIC Module

Advertising