--- title: "mem test" id: 70864 type: "computer_media" slug: "mem-test" url: "http://localhost/computer_media/mem-test/" markdown_url: "http://localhost/computer_media/mem-test.md" published_at: "2026-08-23T15:07:59+00:00" modified_at: "2026-08-23T23:39:27+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "A bare-metal RAM checker that writes three selectable bit patterns across memory, instantly pinpointing any address that fails to read back correctly." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - 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: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/mem%20test%20%28198x%29%28-%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" media_type_tags: "Utility" --- # mem test This program tests RAM integrity by writing a chosen byte pattern to successive memory addresses and verifying each location reads back correctly. Three test patterns are available: all zeros (0x00), all ones (0xFF), and an alternating bit pattern (0x55, binary 01010101). Starting at address 16384—the conventional boundary just above the TS/2068 ROM—it POKEs each address and immediately PEEKs it back, stopping and reporting the failing address and actual value if a mismatch is detected. The current address under test is displayed continuously using PRINT AT 20,0 to update the same screen line in place. *** ### Program Structure The program is short and linear, consisting of four logical phases: 1. Display the menu and accept a pattern selection via `INPUT c$` (lines 10–15). 2. Initialize the starting address pointer `b` to 16383 (line 110). 3. Set the test byte `a` based on the chosen pattern (lines 120–122). 4. Loop: increment address, POKE, PEEK, compare, and either continue or report failure (lines 130–160). ### Test Patterns | Key | Decimal | Hex | Binary | Purpose | | --- | --- | --- | --- | --- | | `a` | 0 | 0x00 | 00000000 | All bits low | | `b` | 255 | 0xFF | 11111111 | All bits high | | `c` | 85 | 0x55 | 01010101 | Alternating bits | The alternating pattern 0x55 (and its complement 0xAA, not included here) is a classic diagnostic value that exercises every other bit line independently, catching stuck-at faults that all-zeros or all-ones tests might miss individually. ### Memory Range The pointer `b` starts at 16383 and is incremented *before* the first POKE, so the first address tested is 16384—the conventional start of RAM above the ROM space. The loop continues upward without an explicit upper bound, meaning it will eventually reach screen memory, system variables, and the BASIC interpreter itself, potentially corrupting the running program. In practice the test is expected to stop at a failing address before causing serious harm, but on a healthy machine it will overwrite everything above 16384. ### Display Technique Line 115 uses `PRINT AT 20,0;b` to continuously overwrite the same screen position with the current address being tested, providing a live progress indicator without scrolling the display. This is a simple but effective use of the `AT` column/row specifier. ### Failure Reporting Line 160 prints the failing address, the value actually read back, and the value that was expected. Execution then falls through to line 1000 (`STOP`), halting the program cleanly after the first detected fault. ### Bugs and Anomalies - **No upper bound:** The test loop has no termination condition other than a PEEK mismatch. On fully working RAM it will run past user RAM into system areas, eventually crashing or corrupting the program itself. - **Single-pattern run:** Only one pattern is tested per run; catching intermittent or pattern-sensitive faults requires manually rerunning the program for each of the three choices. - **Address display before pattern selection:** Line 115 is jumped to before the pattern value `a` is set on the very first pass (because the `GO TO 115` on line 150 re-enters the display step but the first execution flows line 110 → 115 → 120). On the very first iteration `a` is correctly assigned before the first POKE at line 140, so this is harmless in practice, but the structure is slightly misleading. - **Leading zeros in literal:**`LET a=000` on line 120 is valid BASIC but unconventional; the leading zeros have no effect on the numeric value. - **`SAVE` on line 999:** The `SAVE "MEMTEST" LINE 0` statement is embedded in the program flow between the failure report and `STOP`, meaning a failed test would attempt to save the program to tape before halting—an unusual placement that could surprise the user. ## Source Code ``` 5 REM MEMTEST 10 PRINT "THIS IS THE TS/2068 MEMORY TEST.";TAB 0;"SELECT YOUR DESIRED TEST PATERN:";TAB 0;"ALL 0's: a";TAB 0;"ALL 1's: b";TAB 0;"ALTERNATING 0's AND 1's: c" 15 INPUT c$ 110 LET b=16383 115 PRINT AT 20,0;b 120 IF c$="a" THEN LET a=000 121 IF c$="b" THEN LET a=255 122 IF c$="c" THEN LET a=085 130 LET b=b+1 140 POKE b,a 150 IF PEEK b=a THEN GO TO 115 160 PRINT b;" = ";PEEK b;" SHOULD BE ";a 999 SAVE "MEMTEST" LINE 0 1000 STOP ```