This program tests the reliability of a 16 KB cassette tape save-and-load cycle by filling two string arrays with known byte patterns and then verifying them after the tape operation. Two 16,384-character string arrays, A$ and B$, are populated in FAST mode with inverse-E and inverse-Z characters respectively, then saved to tape under the name “TAPE TEST”. After the save (and implied manual rewind and load), each element of both arrays is compared against its expected value, with any mismatches incrementing an error counter. The program estimates approximately 45 minutes of runtime, reflecting the slow speed of ZX81-era cassette storage for large data blocks.
Program Analysis
Program Structure
The program is a linear, single-pass tape diagnostic with four distinct phases:
- Initialisation (lines 10–70): Allocate and fill two 16 KB string arrays with known sentinel characters.
- User prompt (lines 80–100): Pause for the user to prepare the tape recorder before the save begins.
- Save and verify (lines 110–160): Save both arrays to tape, then iterate over every element checking for corruption.
- Report (lines 170–180): Return to SLOW mode and print the total error count.
Array Design
Two string arrays are declared with DIM A$(1,16384) and DIM B$(1,16384). Each is a one-row, 16,384-column string array, consuming exactly 16 KB of RAM per array. Together they occupy the full 32 KB typically available on an unexpanded or 16 KB-expanded machine, which explains the 45-minute runtime estimate on the program header — saving and loading that volume of data over a cassette interface is inherently slow.
Sentinel Values
Array A$ is filled with the inverse-E character (%E) and array B$ with the inverse-Z character (%Z). Using two distinct non-standard characters (inverse video codes, not normal ASCII letters) makes it easier to detect corruption that might accidentally produce a normal character. The verification loop at lines 130–160 checks each position in both arrays and increments the integer variable ERROR for each mismatch found.
FAST / SLOW Mode Usage
The program calls FAST at line 30 before the fill loop to suppress the display interrupt and speed up the population of 32,768 array elements. SLOW is restored at line 170 only after all verification work is complete, so the display remains suppressed throughout the lengthy save, load, and check phases. This is the correct idiomatic approach for bulk data operations.
Notable Techniques and Idioms
- Using
INPUT Z$(line 90) as a simple “press ENTER to continue” gate before the tape operation, avoiding any dependency onINKEY$polling. CLSat line 100 clears the screen immediately before theSAVE, giving a clean display state when the tape header scrolls.- The variable name
ERRORis used as a plain numeric counter; on this platform it does not conflict with any reserved keyword, making the intent self-documenting.
Bugs and Anomalies
The program saves data at line 110 but contains no corresponding LOAD statement. The verify loop at lines 130–160 simply re-checks the in-memory arrays immediately after the save, which means it will always report zero errors — the arrays have not been reloaded from tape. For the test to be meaningful, the operator must manually stop the program after the save, rewind the tape, load it, and then somehow re-run the verification loop independently. This is a significant functional omission; a correct implementation would include a LOAD "TAPE TEST" call between lines 110 and 130.
Additionally, the program uses the variable name A as a loop counter (line 40) while also using A$ as an array name (lines 50, 140). Although this is syntactically valid, it can cause confusion for the reader since A and A$ are distinct variables.
Content
Image Gallery
Source Code
1 SAVE "1018%7"
2 REM 64K TAPE TEST REQUIRES 45 MINS. TO RUN
10 DIM A$(1,16384)
20 DIM B$(1,16384)
30 FAST
40 FOR A=1 TO 16384
50 LET A$(1,A)="%E"
60 LET B$(1,A)="%Z"
70 NEXT A
80 PRINT "START TAPE PRESS ENTER"
90 INPUT Z$
100 CLS
110 SAVE "TAPE TEST"
120 LET ERROR=0
130 FOR X=1 TO 16384
140 IF A$(1,X)<>"%E" THEN LET ERROR=ERROR+1
150 IF B$(1,X)<>"%Z" THEN LET ERROR=ERROR+1
160 NEXT X
170 SLOW
180 PRINT "ERROR COUNT IS ";ERROR
190 STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.