.word $f000 * = $f000 scrptr = $8000 eoscr = $83e7 ; last screen address lastline = $83c0 ; start of last line memstart = $0010 memend = $4000 addr = $0100 aoff = $02 ipass = $03 pbyte = $04 scroff = $0605 main: sei ;; clear screen ldx #scrptr stx >addr ldy #$00 ;; initialize screen pointer lda #scrptr sta >scroff clearloop: lda #" " sta (addr cpx #$84 bne clearloop ;; print infotext ldy #$00 textloop: lda infotext,Y sta lastline,Y iny cpy #$20 bne textloop ;; set up first pass with $FF lda #$00 sta ipass lda #"#" ldy #$00 sta (memstart ldy #addr sty aoff ldy ipass lda passbytes,Y sta pbyte lda passchars,Y sta eoscr loop: ldx >addr ldy aoff ;; break loop when end of DRAM is reached cpx #>memend bne noskip jmp passend noskip: stx eoscr-2 ; show current address as chars on screen sty eoscr-1 ;; store pass value at the current address lda pbyte sta (scroff iny cpy #$00 bne nowrap1 inx cpx #$83 nowrap1: cpx #$83 bne nowrap1a cpy #$98 bne nowrap1a ldx #$80 ldy #$00 nowrap1a: sty scroff ;; upper nibble of X lda >addr lsr lsr lsr lsr tay lda hexchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap2 inx nowrap2: cpx #$83 bne nowrap2a cpy #$98 bne nowrap2a ldx #$80 ldy #$00 nowrap2a: sty scroff ;; lower nibble of X lda >addr and #$0f tay lda hexchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap3 inx nowrap3: cpx #$83 bne nowrap3a cpy #$98 bne nowrap3a ldx #$80 ldy #$00 nowrap3a: sty scroff ;; upper nibble of Y lda aoff lsr lsr lsr lsr tay lda hexchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap4 inx nowrap4: cpx #$83 bne nowrap4a cpy #$98 bne nowrap4a ldx #$80 ldy #$00 nowrap4a: sty scroff ;; lower nibble of Y lda aoff and #$0f tay lda hexchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap5 inx nowrap5: cpx #$83 bne nowrap5a cpy #$98 bne nowrap5a ldx #$80 ldy #$00 nowrap5a: sty scroff ;; space lda #">" ldy #$00 sta (scroff iny cpy #$00 bne nowrap6 inx nowrap6: cpx #$83 bne nowrap6a cpy #$98 bne nowrap6a ldx #$80 ldy #$00 nowrap6a: sty scroff ;; upper nibble of pass char lda ipass asl tay lda passchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap7 inx nowrap7: cpx #$83 bne nowrap7a cpy #$98 bne nowrap7a ldx #$80 ldy #$00 nowrap7a: sty scroff ;; lower nibble of pass char lda ipass asl tay iny lda passchars,Y ldy #$00 sta (scroff iny cpy #$00 bne nowrap8 inx nowrap8: cpx #$83 bne nowrap8a cpy #$98 bne nowrap8a ldx #$80 ldy #$00 nowrap8a: sty scroff ;; upper nibble of actual value ldy aoff lda (scroff iny cpy #$00 bne nowrap9 inx nowrap9: cpx #$83 bne nowrap9a cpy #$98 bne nowrap9a ldx #$80 ldy #$00 nowrap9a: sty scroff ;; lower nibble of actual value ldy aoff lda (scroff iny cpy #$00 bne nowrap10 inx nowrap10: cpx #$83 bne nowrap10a cpy #$98 bne nowrap10a ldx #$80 ldy #$00 nowrap10a: sty scroff ;; print cursor lda #"#" ldy #$00 sta (addr ldy aoff ;; increment memory address iny cpy #$00 bne loopend2 ; branch on overflow (iny sets Z, but not V) inx ; increment y when x overflowed loopend2: stx >addr sty aoff jmp loop passend: ldy ipass lda passbytes,Y cmp #$7F beq eot iny sty ipass jmp pass hexchars: .asc "0123456789ABCDEF" passbytes: .byt $FF, $00, $AA, $55, $01, $02, $04, $08, $10, $20, $40, $80, $FE, $FD, $FB, $F7, $EF, $DF, $BF, $7F passchars: .asc "FF00AA550102040810204080FEFDFBF7EFDFBF7F" infotext: .asc " = MOS6502 memtest 2022, s3lph =" eot: ;; done, loop forever jmp eot ;; Fill with FF * = $fffa .dsb (*-eot-3), $ff ;; 6502 vectors * = $fffa .byt main ; NMIV .byt main ; RESV .byt main ; IRQV