A very effective Applesoft memory test

Here's a simple-but-effective Applesoft program that rigorously tests main memory.

In its first pass, the program uses Applesoft's pseudorandom number generator to fill addresses 4096 through 49151 ($1000 to $BFFF).

In its second pass, it resets the pseudorandom number generator and computes the same sequence again...but this time it compares the values that were previously stored in memory and detects any that don't match.

This method was inspired by the memory test in the Enhanced Apple IIe, which uses a pseudorandom memory fill to test memory.  The original Apple IIe simply filled memory with all-1-bits or all-0-bits, which fails to detect most real-world RAM issues.

NOTE: Do not use with DOS or ProDos.  This program overwrites all main memory, which will crash DOS or BASIC.SYSTEM.

 

10 HIMEM: 4096

20 S = S - 1:R = RND (S)

30 PRINT "FILLING MEMORY WITH PSEUDORANDOM BYTES"

40 FOR A = 4096 TO 49151: POKE A,256 * RND (1): NEXT A

50 PRINT "READING AND COMPARING MEMORY"

60 R = RND (S)

70 FOR A = 4096 TO 49151: R = ABS ( PEEK (A) - INT (256 * RND (1)))

80 IF R = 0 THEN NEXT A: GOTO 20

90 PRINT "BIT MISMATCH ";

100 FOR B = 7 TO 0 STEP -1

110 PRINT INT (R / (2 ^ B)); CHR$ (32);

120 IF R >= (2 ^ B) THEN R = R - (2 ^ B)

130 NEXT B

140 PRINT "AT ";A; CHR$ (7)

150 NEXT A

160 GOTO 20

 

The program takes about ten minutes to fill memory, and another ten minutes to read and compare.

So it's not especially quick, but it's dependable because it requires memory to precisely perform its most basic function: to accurately store and retrieve a large volume of data.

 

Here's a result, with the program detecting bad bits in the high bit at several addresses.  This particular memory chip was indeed faulty.

 

Content Type: