--- title: "64K Memory Test" id: 57338 type: "computer_media" slug: "64k-memory-test" url: "http://localhost/computer_media/64k-memory-test/" markdown_url: "http://localhost/computer_media/64k-memory-test.md" published_at: "2024-10-04T08:26:23+00:00" modified_at: "2026-03-30T21:18:29+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/09/186_64K.png" excerpt: "A two-pass RAM test that pokes every byte of the upper 32 KB with 255 then 0, reporting any failure instantly on-screen and to the printer." 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 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_contents: - id: 56735 title: "Timex Sinclair Public Domain Library Tape 1004" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1004/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/09/186_64K.png" media_type_tags: "Utility" --- # 64K Memory Test This program performs a read/write test of the upper 32 KB of RAM (addresses 32768–65535), checking each byte for both a write-high (255) and write-low (0) cycle. It runs in FAST mode to speed up the scan, dropping to SLOW mode only when an error is detected so the screen can display the failing address. Any detected fault is simultaneously printed to screen at the bottom line and sent to the printer via LPRINT, making it useful for diagnosing faulty RAM expansion hardware. The SCROLL at line 160 ensures the error output remains visible before resuming the fast scan. *** ## Program Analysis ### Program Structure The program is divided into a main loop and a single error-reporting subroutine: 1. **Initialisation (line 10):** Switches to FAST mode for maximum loop speed. 2. **Main test loop (lines 20–80):** Iterates over all 32,768 addresses from 32768 to 65535, performing a write/read test at each location. 3. **Termination (lines 90–110):** Returns to SLOW mode, prints a completion message, and halts. 4. **Error subroutine (lines 140–190):** Called via `GOSUB 140` when a fault is found; reports the bad address on screen and to the printer before returning. ### Memory Test Methodology Each address is tested with a two-pass write/verify cycle: - `POKE I,255` — writes all bits high; `PEEK I` stored in `A` must equal 255. - `POKE I,0` — writes all bits low; `PEEK I` stored in `B` must equal 0. Testing both 0xFF and 0x00 catches stuck-at-high and stuck-at-low bit faults. The condition at line 70 uses `OR` so either failure triggers the error path. ### FAST/SLOW Mode Handling The program uses `FAST` at the start to suppress display refresh and accelerate the POKE/PEEK loop substantially. When an error is detected, the subroutine drops to `SLOW` (line 140) so that the `PRINT AT` at line 150 is visible on screen, then returns to `FAST` (line 170) after outputting to the printer. This toggle ensures error messages are rendered without leaving the program permanently slow during the scan. ### Error Reporting On error, the subroutine reports the failing address `I` in two ways simultaneously: - On-screen: `PRINT AT 21,0;"ERROR AT MEMORY LOCATION: ";I` — always writes to the bottom display line. - Hard copy: `LPRINT "ERROR AT MEMORY LOCATION: ";I` — sends the same message to an attached ZX Printer, providing a permanent fault log. `SCROLL` at line 160 is called between the two output statements to prevent the program halting with `SCROLL?` if multiple errors accumulate on screen. ### Coverage and Limitations The test covers only the upper 32 KB (RAM expansion space, addresses 32768–65535). The lower 32 KB, which includes the system ROM (0–8191) and the base RAM (8192–32767, where the program itself resides), is deliberately excluded — poking the program’s own memory area would corrupt execution. One subtle issue: the test writes `0` to each cell after testing it. This leaves all tested RAM zeroed by the end of the run, which could matter if the program is part of a larger suite, but is harmless for a standalone diagnostic. ### Variable Summary | Variable | Purpose | | --- | --- | | `I` | Current memory address under test (32768–65535) | | `A` | Result of `PEEK` after writing 255; should equal 255 | | `B` | Result of `PEEK` after writing 0; should equal 0 | ## Source Code ``` 1 REM "64K MEMORY TEST" 10 FAST 20 FOR I=32768 TO 65535 30 POKE I,255 40 LET A=PEEK I 50 POKE I,0 60 LET B=PEEK I 70 IF A<>255 OR B<>0 THEN GOSUB 140 80 NEXT I 90 SLOW 100 PRINT "END OF MEMORY TEST" 110 STOP 120 SAVE "1018%6" 130 RUN 140 SLOW 150 PRINT AT 21,0;"ERROR AT MEMORY LOCATION: ";I 160 SCROLL 170 FAST 180 LPRINT "ERROR AT MEMORY LOCATION: ";I 190 RETURN ```