Syntactic Sum Loader

Developer(s): Roderick McConnell
Date: 1982
Type: Program
Platform(s): ZX81, TS 1000
Tags: Utility

Syntax printed a Syntactic Sum after every listing: a checksum of the program area that tells you whether you typed a program exactly as printed. This loader installs the 8K checksum routine in one step. Enter FAST, then RUN. A machine-code routine in the line 1 REM lowers RAMTOP and clears the space above it (the same effect as POKEing RAMTOP and entering NEW), and the program then POKEs the 24-byte Syntactic Sum routine from the hex string in line 10 into that space. It prints 24 BYTES SAVED and the address to call, for example INPUT USR 32744 on a 16K machine.

Now NEW (the routine stays above RAMTOP), type or load a program, and enter PRINT USR with that address to get its Syntactic Sum. Always run the loader in FAST mode; the routine itself works in either mode. The article also explains how to use the loader for other machine-code routines: put the hex in line 10, change line 50 to N+(bytes-1) and line 20 to POKE 16507,(bytes), which must be more than 19.

The article has you type Listing 4, RUN it and enter the decimal bytes of Table 1, then add lines 10-90. The download has the machine code already in the REM. [Editor’s note: the program as printed sums to 19631, 7 less than the printed 19638, by the routine itself; the scan shows nothing else that differs. The download matches the scan.]

Published in Syntax August 1982 (Syntactic Sum Loader).

Image Gallery

Source Code

   1 REM 12345678901234567890123456789012345678901234567
  10 LET A$="XXAF47676FE52A0C40117D402B4EE309E3E5ED52E120F5C1C9"
  20 POKE 16507,24
  30 PRINT USR 16514;" BYTES SAVED"
  40 LET N=PEEK 16388+256*PEEK 16389
  50 FOR X=N TO N+23
  60 LET A$=A$(3 TO )
  70 POKE X,16*(CODE A$-28)+CODE A$(2)-28
  80 NEXT X
  90 PRINT " INPUT USR ";N

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.