Memory Tester

Author(s): Ron Charlton
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v4 n11 (Volume 4, Issue 11)
Date: November 1983
Pages: 5

My ZX/TS’s erratic behavior when it ran big programs made me suspect memory problems. I wrote a BASIC program to perform a simple check of memory above the first 1K of RAM. It found two bytes where a bit was dropped; I fixed the 16K RAM by replacing one chip. This program can help if you suspect a memory problem.

MEMTST writes all zeroes into a byte, confirms that all bits equal zero by reading the byte, writes all ones in the byte, confirms that bits are all ones by re-reading the byte, then moves to the next byte. Lines 70 & 90 record errors.

To use MEMTST, first do the following without line numbers:

POKE 16388,0
POKE 16389,68
NEW
FAST

These POKEs set RAMTOP so the stack resides in the first K of RAM. (So MEMTST will not destroy the machine stack.) Type in MEMTST exactly as shown. In line 20, spell out words except REM. If you SAVE MEMTST, set RAMTOP before you LOAD it.

Run MEMTST. If all goes well, about 4.5 minutes later “END” will appear on the screen. If numbers show up, you have a memory problem.

Each line represents one bad memory location. On each line the first number shows the address of the erring location. The second number contains the code read from the location. The third number is the code written to the location.

To find which bits are bad in a location, convert codes first to hex and then to binary. Read the second number from a line on the screen and find it under the code column in appendix A of the BASIC manual supplied with your computer. Beside the code you will find a two-digit number in the hex column. Interpret each digit according to the following table:

HEX   BITS    HEX   BITS
 0    0000     8    1000
 1    0001     9    1001
 2    0010     A    1010
 3    0011     B    1011
 4    0100     C    1100
 5    0101     D    1101
 6    0110     E    1110
 7    0111     F    1111

For the two hex digits you’ll have 8 bits. Thus, code 127 means hex digits 7F and binary, 01111111. In this example, if the 3rd number was 255, the leftmost bit is in error. (Zero gives all 0’s; 255, all 1’s.)

If the screen fills with errors when you RUN the program, push CONT to see more errors. Repeat until you see “END” displayed. RUN the program several times; some errors show up only on repeated trials.

  10 REM "MEMTST"
20 REM POKE 16388,0 AND POKE 16389,68 AND NEW THEN RUN THIS PROGRAM
30 LET B=0
40 LET C=255
50 FOR A=17408 TO 32767
60 POKE A,B
70 IF (PEEK A)<>B THEN PRINT A,PEEK A;" 0"
80 POKE A,C
90 IF (PEEK A)<>C THEN PRINT A,PEEK A;" 255"
100 NEXT A
110 PRINT "END"
SYNTACTIC SUM: 12889, 8K ROM

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