--- title: "Micro-Wafer Test Program" id: 51161 type: "computer_media" slug: "micro-wafer-test-program" url: "http://localhost/computer_media/micro-wafer-test-program/" markdown_url: "http://localhost/computer_media/micro-wafer-test-program.md" published_at: "2023-07-15T09:08:19+00:00" modified_at: "2026-04-03T07:59:22+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2023/07/Micro-Wafer-Test-Program-cassette.jpg" excerpt: "A diagnostic utility that stress-tests removable wafer media by saving and verifying dozens of test files, then reports free capacity and lists any bad sectors found." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "A & J Micro Drive" slug: "a-j-micro-drive" taxonomy: "post_tag" url: "http://localhost/tag/a-j-micro-drive/" - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Disk Drive Systems" slug: "disk-drive-systems" taxonomy: "genre" url: "http://localhost/type/disk-drive-systems/" - name: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Micro-Wafer%20Test%20Program%20%28198x%29%28US%29%28TS2068%29%28Program%29.zip" mediadate: "198x" producer_company: - id: 10614 title: "A&J Micro Drive" type: "company" url: "http://localhost/company/a-j-micro-drive/" images: - url: "http://localhost/wp-content/uploads/2023/07/Micro-Wafer-Test-Program-cassette.jpg" related_products: - id: 11677 title: "A&J Micro Drive Model 2000" type: "product" url: "http://localhost/product/aj-microdrive/" media_type_tags: "Disk Drive Systems, Utility" --- # Micro-Wafer Test Program This program tests A & J Micro Drive wafers by repeatedly saving and verifying small test files across 52 sectors (ASCII codes 49–100), using ON ERR trapping to detect and record bad sectors. It tracks the number of successfully written sectors in variable S and accumulates a comma-separated string of bad sector numbers in S$. After completing the test loop, it calculates approximate free capacity by multiplying the good-sector count by 3.88K and displays the result along with any bad sector numbers. The large REM statements at lines 200–350 serve as dummy data blocks of known size that the program saves to the wafer during testing. *** ## Program Analysis ### Program Structure The program is organized into four functional regions: 1. **Initialization (lines 91–93):** Sets the successful-sector counter `S` to 1, the bad-sector counter `BS` to 0, and the bad-sector list string `S$` to a space. 2. **Test loop (lines 100–160):** Iterates `A` from 49 to 100 (52 iterations), constructing filenames from `CHR$ A` and attempting a SAVE/VERIFY cycle on each sector. 3. **Results display (lines 3000–3020):** Prints the estimated free capacity and the list of bad sectors, then waits for a keypress before restarting with `RUN` for the next wafer. 4. **Error handler (lines 3500–3810):** Intercepts drive errors, classifies them by error code, and either records a bad sector or halts. ### REM Blocks as Test Data Lines 200 through 350 consist entirely of large `REM` statements packed with repeated characters (`U` and `w` sequences). These are not comments in the conventional sense; they are bulk data embedded in the program itself, sized to give each SAVE operation a meaningful payload. Because the program saves itself (or portions of itself) to the wafer, these padded `REM` lines ensure that each saved file occupies a realistic amount of wafer space and provides a meaningful stress test of each sector. ### Filename Construction The loop variable `A` runs from 49 to 100, covering ASCII characters `1` through `d`. Three string variables are constructed each iteration: - `A$` = `CHR$ A` — a single distinguishing character. - `B$` = `"TEST"` + `A$` — the filename for the saved file (e.g., `TEST1`, `TEST2`, …). - `C$` = `"@"` + `A$` + `","` + `B$` — the SAVE target specifying the drive/sector. - `D$` = `"@"` + `B$` — the VERIFY source. Lines 1000–1020 save three short named files (`A`, `B`, `C`) to drives 1–3 respectively, seemingly as a calibration or warm-up step before the main loop begins — though they fall outside the loop and are only reached if execution flows past line 160. ### Error Handling Strategy The program makes careful use of ON ERR to handle drive failures non-fatally: - Line 135 arms the error trap to jump to the handler at line 3500 before each SAVE. - Line 155 resets the error trap after a successful VERIFY, so normal execution resumes cleanly. - The handler at line 3500 reads the system error code variable via `PEEK 23739` into `Z`. - Error code 8 (interpreted as a successful end-of-wafer or capacity condition) branches to the results display at line 2999. - Error code 21 (a more serious or unrecoverable error) branches to line 3800, which resets the trap and halts. - Any other error is treated as a bad sector: a message is printed, `BS` is incremented, `S` is decremented, and the bad sector number (`A-48`, converting ASCII back to a 1-based sector number) is appended to `S$`. ### Capacity Calculation At line 3002, the estimated free capacity is printed as `S * 3.88` kilobytes. The multiplier 3.88 reflects an empirical per-sector storage figure for the wafer format. Since `S` starts at 1 and is incremented before each SAVE (line 137) but decremented on error (line 3610), the final value of `S` approximates the number of sectors successfully written. ### Bad Sector Reporting Bad sector numbers are accumulated in `S$` as a comma-separated string using `STR$` concatenation (line 3620). The sector number displayed is `A-48`, converting the ASCII loop index back to a human-readable integer. This string is printed verbatim at line 3005. ### Multi-Wafer Operation After displaying results, line 3010 waits for any key using the `IF INKEY$ = "" THEN GO TO 3010` idiom, then line 3020 executes `RUN`, which reinitializes all variables and restarts from line 91, allowing sequential testing of multiple wafers without manual program restart. ### Notable Anomalies - Lines 1000–1020 save files to drives 1, 2, and 3 unconditionally but are positioned after the loop at line 160, which ends with `NEXT A` and falls through to line 200 (a `REM`). Normal execution after the loop would flow from line 160 to line 200 onwards through the `REM` blocks and on to line 1000, which may be unintentional, or these saves may be a secondary test stage. - Line 4000 onward contains a `SAVE "TEST"` and a `BEEP` followed by another `SAVE "TEST"`. These lines are unreachable during normal program flow and appear to be a mechanism for saving the test program itself to tape. - The bad-sector counter `BS` is incremented at line 3610 but never displayed in the results — only the string `S$` listing sector numbers is shown. ## Source Code ``` 91 LET S=1 92 LET BS=0 93 LET S$=" " 100 FOR A=49 TO 100 110 LET A$=CHR$ A 115 LET B$="TEST"+A$ 120 LET C$="@"+A$+","+B$ 130 LET D$="@"+B$ 135 ON ERR GO TO 3500 137 LET S=S+1 140 SAVE C$ 150 VERIFY D$ 155 ON ERR RESET 160 NEXT A 200 REM UUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUU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wwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU 1000 SAVE "@1,A" 1010 SAVE "@2,B" 1020 SAVE "@3,C" 2999 ON ERR RESET 3000 CLS 3002 PRINT AT 0,0;"THE WAFER HAS APPROXIMATELY ",;S*3.88;"K-BYTE S FREE."; 3005 PRINT AT 4,0;"THE FOLLOWING SECTORS WERE BAD:",;S$ 3007 PRINT AT 8,0;"REMOVE WAFER AND INSERT NEXT WAFER FOR TES TING, THEN PRESS ANY KEY." 3010 IF INKEY$ = "" THEN GO TO 3 010 3020 RUN 3499 STOP 3500 LET Z=PEEK 23739 3505 ON ERR RESET 3510 IF Z=8 THEN GO TO 2999 3520 IF Z=21 THEN GO TO 3800 3600 PRINT "THERE HAS BEEN AN ER ROR DETECTEDON SECTOR #";A-48;". ",,"CONTINUING TO TEST WAFER." 3610 LET BS=BS+1: LET S=S-1 3620 LET S$=S$+STR$ S+"," 3700 GO TO 155 3800 ON ERR RESET 3810 STOP 4000 SAVE "TEST" 4010 BEEP 2,2 4030 SAVE "TEST" ```