Loading with the Syntactic Sum is a simple way to guarantee that programs loaded by the 8K ROM don’t run if they suffer from parity problems.
The following program utilizes a technique from SYNTAX’s Syntactic Sum program. First, LOAD the Syntactic Sum program and another program. When you SAVE the second program on tape, the Syntactic Sum program is called. The value returned is saved in variable B. Next, the program and the variable are saved to tape.
The next time you LOAD your program, the Syntactic Sum will be called and compared to the value obtained when you saved your program. If the two values do not match, a parity error has occured and the program stops before executing. The address 18400 in 9990 is the location of the Syntactic Sum program for a 2K RAM and must be adjusted for other RAM sizes.
9990 LET U=18400
9991 IF PEEK U=33 THEN LET B=USR U
9992 SAVE "PROG"
9993 IF PEEK U<>33 THEN RUN
9994 LET A=USR U
9995 IF A=B THEN RUN
9996 PRINT "ERROR S/S=";A,,"WANTED=";B
9997 STOP
9998 RUN
SYNTACTIC SUM: 9272, 8K
These comments correspond to the preceding program:
9990 Point to Syntactic Sum area.
9991 If 'ss' is in storage get
checksum value.
9992 Save program with Checksum
Variable.
9993 'ss' is not in storage,
ignore.
9994 Get loaded Checksum value.
9995 Checksum at LOAD time is the
same as at SAVE time; ok to
execute.
9996 Inform operator of error.
9997 Wait for operator reply.
9998 Ignore error, continue to
execute.
10 LET P=855106
20 FOR X=0 TO 8191
30 LET P=P-PEEK X
40 NEXT X
50 IF P=0 THEN PRINT "ROM OK"
New 8K ROM test–good ROMs give OK.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.