Syntactic Sum Loader

Author(s): Roderick McConnell
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v3 n8 (Volume 3, Issue 8)
Date: August 1982
Pages: 20-21

New Readers: Syntactic Sum is a machine code routine devised by SYNTAX to help you assure correct program entry. If two people type a program exactly the same, they get the same Syntactic Sum. If one makes an error, the Sums differ. The Sum we get when we test each program appears after the last line of the published version, along with the ROM designation. The following loader program greatly simplifies using Syntactic Sum for 8K ROM programs.–AZ


This program provides a Syntactic Sum machine language routine in just one step instead of the original multi-step process. Just LOAD and RUN it, and the Syntactic Sum program is resident. It also prints the starting address of the subroutine for the USR call.

The first part, Listing 1, consists of a REM statement holding all the machine code needed to move the Z80 microprocessor stack and change all appropriate system variables. This has the same effect as POKEing a new value into the system variable RAMTOP, then executing a NEW. The second part POKEs a Syntactic Sum subroutine into the newly created space at the top of memory.

To enter this program, follow these steps:

1. Enter the program in Listing 4.

2. RUN it.

3. INPUT the values in Table 1. Read them across and press ENTER or NEWLINE after each. After the last one, the REM statement in line 1 should have changed to look like line 1 in Listing 1 following.

4. Enter lines 10-90 of Listing 1, replacing lines 10-40 of listing 4.

To use this program, type RUN. ALWAYS RUN THIS PROGRAM IN THE FAST MODE. If you SAVE it in FAST, you’ll just have to LOAD and RUN it.

When you run this program, it returns the number of bytes saved above RAMTOP and the starting address of the subroutine (INPUT USR nnnnn). You can access the routine anytime by entering PRINT USR nnnnn where nnnnn is the address displayed. The computer does not have to be in FAST mode to use Listing 1. To clear the Syntactic Sum loader program from memory before typing or loading a program, hit NEW and ENTER or NEWLINE.

This program automatically calculates locations, so you can use it with any size memory with no changes.

You can also use it to load other subroutines: Put the code (in hex) in line 10. The first two characters of A$ are lost in conversion, so start your code with the third character. Change line 50 to TO N+(# of bytes – 1). Change line 20 to POKE 16507,(number of bytes). WARNING–you must POKE a number greater than 19 or the computer crashes. You can also use this program to load more than one subroutine at a time. Each time the program is run, the subroutine will be put at the top of available memory.

This program, together with other self-loading utilities, is available on cassette for $4.00.

Roderick McConnell, 28 Orchard St., Glen Head, NY 11545

Listing 1

Listing 1, line 1 REM statement
Listing 1, line 1 REM statement
  10 LET A$="XXAF47676FE52A0C40117D40254EE309E3E5ED52E120F5C1C9"
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
SYNTACTIC SUM: 19638, 8K

LISTING 4

   1 REM 12345678901234567890123456789012345678901234567
10 FOR X=16514 TO 16560
20 INPUT N
30 POKE X,N
40 NEXT X

TABLE 1–read across

175   42    4   64  237  114
 68   77    3   57  237   91
123   64  237   82  235   25
237  184  237   75  123   64
 42    4   64  237   66   34
  4   64   42    2   64  237
 66   34    2   64  237   98
 57  237   66  249  201

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