--- title: "Syntactic Sum – ZX80" id: 77777 type: "computer_media" slug: "syntactic-sum-zx80" url: "http://localhost/computer_media/syntactic-sum-zx80/" markdown_url: "http://localhost/computer_media/syntactic-sum-zx80.md" published_at: "2026-11-18T16:43:13+00:00" modified_at: "2026-11-18T16:43:13+00:00" featured_image: url: "http://localhost/wp-content/uploads/2026/11/syntactic-sum-zx80-1.png" excerpt: "Calculate the Syntactic Sum of a ZX80 BASIC program, to check your typing against the number Syntax printed under each listing." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "ZX80" slug: "zx80" taxonomy: "post_tag" url: "http://localhost/tag/zx80/" model: - name: "Sinclair ZX80" slug: "zx80" taxonomy: "model" url: "http://localhost/model/zx80/" genre: - name: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Syntactic%20Sum%20-%20ZX80%20%281981%29%28-%29%28ZX80%29%28US%29%28Program%29.zip" mediadate: "1981" images: - url: "http://localhost/wp-content/uploads/2026/11/syntactic-sum-zx80-1.png" article_media: - id: 19247 title: "Syntactic Sums" type: "article" url: "http://localhost/article/syntactic-sums/" media_type_tags: "Utility" license: false --- # Syntactic Sum – ZX80 A 31-byte machine-code routine for the ZX80 (4K ROM) that adds up the bytes of the BASIC program in memory and returns the total, the Syntactic Sum that Syntax printed under its listings so readers could find typing mistakes. Program 1 lowers the top of memory (a technique credited to David Ornstein of Sinclair Research) to protect the routine from BASIC; Program 2 INPUTs the 31 decimal bytes into an array and POKEs them into the protected area. You then type PRINT USR(17376) on a 1K machine. Line 20 of Program 1 is printed as POKE 17153,M-(M/256), not M-(M/256)*256. The ZX80 keeps only the low byte, so it still works but reserves 100 bytes instead of 32. The download has both programs: load and RUN Program 1, then LOAD Program 2 and type GO TO 6 (not RUN, which would clear the array holding the bytes). Program 2 is saved the way the article tells you to save it, with lines 1-5 deleted and the 31 bytes already in its array, so there is nothing to type in. The programs are set for a 1K ZX80; with more memory, change line 6 in both as the article explains. Published in Syntax February 1981 ([Syntactic Sums](https://timexsinclair.com/article/syntactic-sums/)). ## Source Code ``` PROGRAM 1 6 LET M=1024 7 LET M=M+16351 10 POKE 17152,33 20 POKE 17153,M-(M/256) 30 POKE 17154,M/256 40 POKE 17155,195 50 POKE 17156,107 60 POKE 17157,2 70 LET X=USR(17152) PROGRAM 2 1 DIM P(31) 2 FOR L=1 TO 31 3 INPUT P(L) 4 NEXT L 5 STOP 6 LET M=1024 7 FOR L=M+16352 TO M+16382 8 POKE L,P(L-M-16351) 9 NEXT L DECIMAL LISTING 33 40 64 237 91 8 64 221 33 0 0 124 186 32 8 125 187 32 4 221 229 225 201 78 6 0 221 9 35 24 236 ```