* * tm.asm - memory test program for Radio Shack color computer * * Jan 1996 WJY * 2-Feb-96 855pm WJY - v0.3 - data & program in contiguous memory * 9-Feb-96 150am WJY - v0.4 - corrected hex output routine * 11-Feb-96 250pm WJY - v0.5 - map in RAM, keep current counters, * mark page by inverse video, * correctly index error count table * 11-Feb-96 650pm WJY - v0.6 - fixed pattern number increment * 14-Feb-96 1130am WJY - v0.7 - load .y for page test, * fixed hex1a * 20-Feb-96 1235mn WJY - v0.8 - check for & warn about address wrap * fill map with X's for wrapped part * org #$3000 *************************************************************************** * initialized data * * 6847 hacked ASCII constants SPACE equ $60 ZERO equ $70 DASH equ $6d COLON equ $7a DOT equ $6e display * fcc " COCO MEMORY TEST V0.8 WJY 1996 " fcb SPACE,'C,'O,'C,'O,SPACE,'M,'E,'M,'O,'R,'Y fcb SPACE,'T,'E,'S,'T,SPACE,'V,ZERO+0,DOT,ZERO+8 fcb SPACE,'W,'J,'Y,SPACE,ZERO+1,ZERO+9,ZERO+9,ZERO+6 fcb SPACE * fcc " " fill SPACE,32 * fcc " PAGE ERRORS " fcb SPACE,SPACE,SPACE,SPACE,'P,'A,'G,'E fill SPACE,14 fcb 'E,'R,'R,'O,'R,'S,SPACE,SPACE,SPACE,SPACE * fcc "BIT 0123456789ABCDEF ADDR WR RD" fcb 'B,'I,'T,SPACE fcb ZERO,ZERO+1,ZERO+2,ZERO+3,ZERO+4 fcb ZERO+5,ZERO+6,ZERO+7,ZERO+8,ZERO+9 fcc "ABCDEF" fcb SPACE,SPACE,'A,'D,'D,'R,SPACE,'W,'R,SPACE,'R,'D * fcc " 0 " fcb SPACE,SPACE,ZERO+0,SPACE fill $f0,16 fill SPACE,12 * fcc " 1 " fcb SPACE,SPACE,ZERO+1,SPACE fill $f0,16 fill SPACE,12 * fcc " 2 " fcb SPACE,SPACE,ZERO+2,SPACE fill $f0,16 fill SPACE,12 * fcc " 3 " fcb SPACE,SPACE,ZERO+3,SPACE fill $f0,16 fill SPACE,12 * fcc " 4 " fcb SPACE,SPACE,ZERO+4,SPACE fill $f0,16 fill SPACE,12 * fcc " 5 " fcb SPACE,SPACE,ZERO+5,SPACE fill $f0,16 fill SPACE,12 * fcc " 6 " fcb SPACE,SPACE,ZERO+6,SPACE fill $f0,16 fill SPACE,12 * fcc " 7 " fcb SPACE,SPACE,ZERO+7,SPACE fill $f0,16 fill SPACE,12 * fcc " " fill SPACE,32 * fcc " PASS:---- PATTERN:-- " fcb SPACE,SPACE,'P,'A,'S,'S,COLON,DASH,DASH,DASH,DASH fill SPACE,7 fcc "PATTERN" fcb COLON,DASH,DASH,SPACE,SPACE,SPACE,SPACE * fcc " ERRORS:---- " fcb SPACE,SPACE fcc "ERRORS" fcb COLON,DASH,DASH,DASH,DASH fill SPACE,19 * fcc " " fill SPACE,32 * display offsets dispag equ 100 list of page numbers dismap equ 132 memory map disetb equ 150 error table dispas equ 423 pass number dispat equ 442 pattern number diserr equ 457 error count dismsg equ 482 message area pasnum fdb 0 patnum fcb 0 patlen fcb 0 patdat fdb 0 pcount fcb 0 pagnum fcb 0 pagbeg fdb 0 paglen fdb 0 pagend fdb 0 mypage fcb 0 bltto fdb 0 bltfrom fdb 0 bltend fdb 0 errors fdb 0 errstr fdb 0 erradr fdb 0 errwr fcb 0 errrd fcb 0 errtab zmb 256 stack zmb 256 stcktop equ * *************************************************************************** * constant data * pagnumh fcb $0f patnumh fcb 5 highest pattern number pattab fcb 1 pattern length fdb pat0-display relative address fcb 0 fcb 1 fdb pat1-display fcb 0 fcb 2 fdb pat2-display fcb 0 fcb 2 fdb pat3-display fcb 0 fcb 8 fdb pat4-display fcb 0 fcb 8 fdb pat5-display fcb 0 * None of these patterns should contain $60, the CoCo's * display code for the SPACE character, because the first * character of the display screen is tested for overwriting * due to address-wraparound. If that character was in one * of the test patterns, such a wraparound might not be * detected. pat0 fcb $00 patterns pat1 fcb $ff pat2 fcb $aa,$55 pat3 fcb $cc,$33 pat4 fcb $01,$02,$04,$08,$10,$20,$40,$80 pat5 fcb $7f,$bf,$df,$ef,$f7,$fb,$fd,$fe *************************************************************************** * program * start orcc #$50 disable interrupts leas stcktop,pcr initialize the stack pointer leax display,pcr point SAM to the display tfr x,d lsra ldx #samdisp ldb #7 lbsr sam lda #1 tell SAM to forget the ROMs ldx #samtype ldb #1 lbsr sam ldd #1 start with pass number one std pasnum,pcr newpas ldd pasnum,pcr display pass number leax display,pcr leax dispas,x lbsr hex4 ldd #0 no errors yet std errors,pcr leax display,pcr display number of errors leax diserr,x lbsr hex4 clr patnum,pcr start with pattern 0 newpat lda patnum,pcr display pattern number leax display,pcr leax dispat,x lbsr hex2 lda patnum,pcr find pattern & length lsla lsla leax pattab,pcr leax a,x ldb ,x stb patlen,pcr ldd 1,x std patdat,pcr clr pagnum,pcr start with page 0 newpag lda pagnum,pcr display the page number leax display,pcr leax dispag,x ldb a,x andb #$BF inverse video for current page number stb a,x cmpa #15 page 15 is special - memory mapped I/O, etc. beq npag1 ldx #$1000 not last page - test all of it bra npag2 npag1 ldx #$0f00 last page - test most of it npag2 stx paglen,pcr lsla calculate page bounds lsla lsla lsla clrb std pagbeg,pcr first address addd paglen,pcr std pagend,pcr last npag3 leax npag3,pcr self-copy if necessary tfr x,d lsra lsra lsra lsra .a has program's current page num sta mypage,pcr cmpa pagnum,pcr bne testpag not testing this page - go ahead tfr x,d calculate self-copy 'from' addresses... clrb anda #$f0 std bltfrom,pcr addd #$1000 std bltend,pcr tst mypage,pcr ...and the 'to' address bne npag4 ldx #$1000 move to page 1 bra npag5 npag4 ldx #$0000 move to page 0 npag5 stx bltto,pcr ******** block transfer blt ldx bltfrom,pcr ldy bltto,pcr bltloop ldd ,x++ std ,y++ cmpx bltend,pcr bne bltloop leax >moved,pcr calculate new address of "moved" label tfr x,d subd bltfrom,pcr addd bltto,pcr tfr d,x jmp ,x jump to it moved leas stcktop,pcr begin life in the new page leax display,pcr tell SAM where the display now resides tfr x,d lsra ldb #7 ldx #samdisp lbsr sam testpag ldy pagbeg,pcr point to the page we're testing nextstr leax display,pcr start test pattern string ldd patdat,pcr leax d,x ldb patlen,pcr stb pcount,pcr testbyt lda ,x test a byte sta ,y cmpa ,y beq testwrp lbsr error report an error testwrp lda #SPACE test for address-wraparound cmpa display,pcr beq incbyt sta display,pcr lbsr wrap lda pagnum,pcr decrease the highest page number sta pagnumh,pcr cmpy pagbeg,pcr bne incpag if only at the first byte, deca pagnum,pcr count this page as too high also bra incpag done with this whole page now incbyt leay 1,y increment byte pointers leax 1,x cmpy pagend,pcr beq incpag dec pcount,pcr beq nextstr bra testbyt incpag lda pagnum,pcr increment page number leax display,pcr leax dispag,x ldb a,x orb #$40 set page number back to normal video stb a,x inca next page cmpa pagnumh,pcr bhi incpat sta pagnum,pcr lbra newpag incpat lda patnum,pcr increment pattern number inca cmpa patnumh,pcr bhi incpas sta patnum,pcr lbra newpat incpas ldd pasnum,pcr increment pass number addd #1 std pasnum,pcr lbra newpas *************************************************************************** * subroutines * hex8 bsr hex4 output 8 hex digits to .x+: .d .y tfr y,d hex4 bsr hex2 output 4 hex digits: .d tfr b,a hex2 pshs a output 2 hex digits: .a lsra lsra lsra lsra bsr hex1 puls a anda #$0f hex1 cmpa #9 output 1 hex digit: .a LSN bhi hex1a adda #ZERO bra hex1s hex1a adda #'A-10 if it was 10, make it into 'A hex1s sta ,x+ rts sam lsra set .b SAM bits from .a, starting at .x bcs sam1 sta ,x bra sam2 sam1 sta 1,x sam2 leax 2,x decb bne sam rts wrap pshs x,y report a wraparound leax display,pcr leax dismsg,x leay >wmsg1,pcr bsr strcpy ldd pagbeg,pcr lbsr hex4 leay >wmsg2,pcr bsr strcpy leay display,pcr tfr y,d lbsr hex4 leay display,pcr leay dismap,y lda pagnum,pcr leay a,y ldb #'X-64 wrap2 stb ,y stb 32,y stb 64,y stb 96,y stb 128,y stb 160,y stb 192,y stb 224,y leay 1,y inca cmpa #15 bls wrap2 puls x,y rts wmsg1 fcb 'W,'R,'A,'P,SPACE,'F,'R,'O,'M,SPACE,0 wmsg2 fcb SPACE,'T,'O,SPACE,0 strcpy lda ,y+ copy [.y+...] to [.x+...] beq strcpy9 sta ,x+ bra strcpy strcpy9 rts error stx errstr,pcr report an error sty erradr,pcr remember current pointers sta errwr,pcr lda ,y sta errrd,pcr ldd errors,pcr count another memory error addd #1 std errors,pcr leax display,pcr display it leax diserr,x lbsr hex4 leax display,pcr scroll error data on display leax disetb,x ldb #7 errscr ldy 32,x addr1 sty ,x ldy 34,x addr2 sty 2,x ldy 37,x wr sty 5,x ldy 40,x rd sty 8,x leax 32,x decb bne errscr ldd erradr,pcr done scrolling - display new error info lbsr hex4 addr leax 1,x lda errwr,pcr lbsr hex2 wr leax 1,x lda errrd,pcr lbsr hex2 rd ldb pagnum,pcr calculate display address leay display,pcr leay dismap,y leay b,y lslb calculate error table address lslb = errtab base address + 16 * page number lslb lslb clra don't just use .b, which would be 2's comp leax errtab,pcr leax d,x lda errwr,pcr eora errrd,pcr err2 lsra bcc err2z pshs a ldd ,x cmpd #65535 beq err2a too big - can't increment addd #1 count another error for this bit std ,x err2a cmpd #16 small error count? bhs err2b lda #$b2 red lower left block bra err2m err2b cmpd #256 medium-small error count? bhs err2c lda #$ba red left blocks bra err2m err2c cmpd #4096 medium-big error count? bhs err2d lda #$bb red lower and left blocks bra err2m err2d lda #$bf big error count - all red blocks err2m sta ,y puls a err2z leax 2,x next errcount immediately follows previous leay 32,y next bit is one row down tsta bne err2 ldy erradr,pcr restore memory-test pointers ldx errstr,pcr zzzend rts *************************************************************************** * SAM addresses * samvdgm equ $ffc0 video display mode samdisp equ $ffc6 display address offset sampage equ $ffd4 page #1 samrate equ $ffd6 cpu rate samsize equ $ffda memory size samtype equ $ffde memory map type end start