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: 

Comments

S.Elliott's picture

If memory errors arise, the faulty chip can be identified by using the table below.  Find the row whose address range includes the address of the bit mismatch, then look for the column corresponding to any "1"  that appears in the list of mismatched bits.

 

For example, the message "BIT MISMATCH 1 0 0 0 0 0 0 0 AT 8734" pictured above means there's a fault in the RAM chip at socket C10.

Bit error-to-chip map
Address rangebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0
0-16383C10C9C8C7C6C5C4C3
16384-32767D10D9D8D7D6D5D4D3
32768-49151E10E9E8E7E6E5E4E3

 

Thank you very much, this works really well. I used it to test the memory of my Apple ][ and used my Keyboard Serial Terminal board (see this post) to auto type it.