Program Improvements

Author(s): Lloyd Painter; Stephen Brothers
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v4 n8 (Volume 4, Issue 8)
Date: August 1983
Pages: 3-4

As noted in Jun.83, my BASIC Syntactic Sum (Feb.83) can give a different result than the MC version when checking long programs. This improvement gives the same result as the MC version, whatever the program length.

Just enter these lines at the end of your program, then GOTO 9600 to calculate the Syntactic Sum.

9600 FAST
9601 LET S=0
9602 LET K=65536
9603 FOR A=16509 TO PEEK 16396+256*PEEK 16397-1
9604 LET S=S+PEEK A
9605 NEXT A
9606 LET S=S-K*INT (S/K)
9607 PRINT "S=";S-10310
9608 STOP
SYNTACTIC SUM: 10310, 8K ROM

If you want to use this program with different line numbers, first enter it by itself, using your line numbers and replacing the 10310 at the end of line 9607 with a single 0. RUN it and jot down the value of S. Then enter the following program, using the S value you wrote down for the value of D in line 10:

   5 REM --- USE THE NUMBER YOU WROTE DOWN IN PLACE OF XXX WHEN YOU TYPE LINE 10
10 LET D=XXX
15 LET E=D
20 LET D$=STR$ D
25 LET V=PEEK 16400+256*PEEK 16401
30 LET F=0
35 FOR N=1 TO 5
40 LET F=F+PEEK (V+N)
45 NEXT N
50 LET C=0
55 FOR N=1 TO LEN D$
60 LET C=C+CODE D$(N)
65 NEXT N
70 LET S=E-28-1+LEN D$+F+C-D
75 LET G=ABS S
80 IF G<=30 AND G/3=INT (G/3) THEN PRINT D,S
85 IF S=0 THEN STOP
90 LET D=D+1
95 GOTO 20
SYNTACTIC SUM: 22228, 8K ROM

Make sure your machine is in FAST. RUN, then go dry the dishes or walk the dog. When you return, the computer should show a 0 in the right column. Substitute the corresponding number in the left column for the 0 in the next-to-last line of Syntactic Sum. DELETE the second program and RUN Syntactic Sum. Now S should equal 0.

If the second program never gives you a 0, press BREAK. (If no numbers appear on the screen, enter CONT and press BREAK again later.) Pick the smallest absolute value in the right column. Divide it by 3 and reverse the sign (multiply by -1). Change the three K variables in lines 9602 and 9606 to the letter that number ahead of or behind K in the alphabet. For example, if the number is +2, change K to M (K +2 letters = M). Revise the next to last line as explained in the previous paragraph (substitute the corresponding number…).

Lloyd Painter, Quakertown, PA


To execute 8K MC Video Invert (Jun.83) more easily, enter this loader program (line 1 contains 28 characters after REM):

   1 REM ABCDEFGHIJKLMNOPQRSTUVWXYZAB
10 FOR A=16514 TO 16541
20 INPUT X
30 SCROLL
40 PRINT X,;CHR$ X
50 SCROLL
60 POKE A,X
70 NEXT A

RUN, then input the decimal numbers from Jun.83, p.21. After the last number, delete lines 10-70. To use the routine, enter RAND USR 16514.

Stephen Brothers, Aurora, CO

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