64K Memory Test

This file is part of and Timex Sinclair Public Domain Library Tape 1004. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Utility

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

VariablePurpose
ICurrent memory address under test (32768–65535)
AResult of PEEK after writing 255; should equal 255
BResult of PEEK after writing 0; should equal 0

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10176 – 10210.

Related Products

Related Articles

Related Content

Image Gallery

64K Memory Test

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 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top