ô > RAMTest/s Bô Based on www.willegal.net/appleii/6502mem.htm translation of :ô Carl Moser's 6502 RAM test in Issue 1 Compute, 1979. (: 2-ô Destructively tests almost all 6502 RAM <#ô Run on I/O, tests &0E00-&7FFF F$ô Run on Tube, tests &0500-&F7FF P$ô On error, prints pp aaaa bb tt Z;ô pp=pass, aaaa=address, bb=byte from ram, tt=test byte d: nCô On completion, language memory zeroed and language re-entered x: ‚7OSRDCH=&FFE0:OSNEWL=&FFE7:OSWRCH=&FFEE:OSBYTE=&FFF4 ŒÞ mcode% &180 –:  start=&80:end=&82:addr=&84 ªtest=&86:pass=&87 ´: ¾ ã P=0 ¸ 1 ÈP%=&400:O%=mcode% Ò[OPT P*3+4 Ü .exec% æ6JMP go%:BRK:BRK:BRK \ Header identifies ð6EQUB &42:EQUB copy-exec% \ this as 6502 code úEQUB &10:EQUS "RAMTEST" &EQUB &00:EQUS "1.00 (15 Feb 2010)"  .copy &EQUB 0:EQUS"(C)J.G.Harston":EQUB 0 ": ,.go% 6ELDA #&82:JSR OSBYTE \ What side of the Tube are we on? @7LDA #&0E:LDX #&80 \ start, end for I/O JINY:BEQ setlimits T8LDA #&05:LDX #&F8 \ start, end for Tube ^.setlimits h;STA start+1:STX end+1 \ Set memory test limits r:LDA #0:TAY \ Initial test byte=&00 |\STA start+0:\STA end+0 † .loop0  STA test š: ¤\ Test type in Y ®\ 0 = all zeros ¸\ 1 = all ones Â"\ 2 = move 1s up through bytes Ì"\ 3 = move 0s up through bytes Ö\ 4 = low byte of address à\ 5 = high byte of address ê\ 6 = all zeros again ô: þ3\ Test all memory with test byte specified by Y 3\ ---------------------------------------------  .loop1 \LDA start+0:\STA addr+0 &ELDX #0:STX addr+0 \ Point to start of memory to test 0LDA start+1:STA addr+1 :: D.\ On pass 4 and 5 use address as test byte N.\ ---------------------------------------- X .loop2 bBLDA addr+0:CPY #4:BCC testbyte \ pass<4, use current test byte lDBEQ setbyte \ pass=4, use low byte of address vELDA addr+1:CPY #6:BCS testbyte \ pass=5, use high byte of address € .setbyte Š STA test ”: ž!\ Test memory with test value ¨!\ --------------------------- ² .testbyte ¼2LDA test \ Get test byte ÆLSTA (addr,X):LDA (addr,X) \ Store test byte and fetch it back again ÐLCMP test:BEQ no_error \ Fetched value didn't match stored value Ú: ä\ Error occured, report it î\ ------------------------ ø3PHA \ Save test byte 7TYA:JSR PrHex \ Output pass number  LDA addr+1:JSR PrHexSpc 3LDA addr+0:JSR PrHex \ Output address  7PLA:JSR PrHexSpc \ Output actual byte *5LDA test:JSR PrHexSpc \ Output test byte 4JSR OSNEWL >: H .no_error R9INC addr+0:BNE P%+4:INC addr+1 \ Step to next address \%\LDA addr+0:\CMP end+0:\BNE loop2 f8LDA addr+1:CMP end+1:BNE loop2 \ Loop to test memory p: z.\ All memory tested, prepare for next pass „.\ ---------------------------------------- ŽCPY #1:BCC next0:BEQ next1 ˜CPY #3:BCC next2:BEQ next3 ¢CPY #5:BEQ next5:BCS done ¬I: \ Drop through to INC Y and loop back ¶ .next0 ÀBDEC test:INY:BNE loop1 \ test byte=&FF, retest memory Ê .next1 ÔBSTY test:INY:BNE loop1 \ test byte=&01, retest memory Þ .next2 èDROL test:BCC loop1 \ Move set bit up, retest memory òQLDA #&FE:STA test:INY:BNE loop1 \ Set bits done, test byte=&FE, retest memory ü .next3 FROL test:BCS loop1 \ Move clear bit up, retest memory  .next5 GLDA #0:INY:BNE loop0 \ Clear bits done, do address bytes $: . .done 8LDA #—"O":JSR OSWRCH BLDA #—"K":JSR OSWRCH L9JSR OSRDCH:JSR OSNEWL \ Wait for a keypress V9LDA #252:LDY #255 \ X will still be &00 `?JSR OSBYTE:LDA #142:JMP OSBYTE \ Re-enter current language j: t .PrHexSpc ~9PHA:LDA #—" ":JSR OSWRCH:PLA \ Print a leading space ˆ .PrHex ’PHA:LSR A:LSR A:LSR A:LSR A œJSR PrNyb:PLA ¦ .PrNyb °!€ #15:CMP #10:BCC P%+4:ADC #6 ºADC #—"0":JMP OSWRCH Ä]:í Î;ñ"*SAVE RAMTEST ";~mcode%;" ";~O%;" ";~exec%;" ";~exec% ÿ