audit: convert langcard tests to executable style

This commit is contained in:
Zellyn Hunter 2017-04-24 21:06:55 -04:00
parent b98edea9a0
commit dda6de609e
5 changed files with 181 additions and 168 deletions

View File

@ -193,6 +193,7 @@ end:
!src "monitor-routines.asm"
!src "keyboard.asm"
!src "video.asm"
!src "printtest.asm"
;!src "shasumtests.asm"
print

Binary file not shown.

View File

@ -205,7 +205,7 @@ AUXMEMTESTS
sta .checkdata+1
;; First checkdata byte is for Cxxx tests.
jsr .nextcheck
jsr NEXTCHECK
bmi +
jsr .checkCxxx
@ -218,7 +218,7 @@ AUXMEMTESTS
;; Do the next part twice.
lda #1
sta .ismain
jsr .nextcheck
jsr NEXTCHECK
.checkloop ; Loop twice here: once for main, once for aux.
lda #4
sta .region
@ -241,7 +241,7 @@ AUXMEMTESTS
beq .memlp
.memlpinc
jsr .nextcheck
jsr NEXTCHECK
dec .region ; loop four times: zero, main, text, hires
bne .memlp
@ -463,45 +463,12 @@ AUXMEMTESTS
+printed
rts
;;; Increment .checkdata pointer to the next memory location, and load
;;; it into the accumulator. X and Y are preserved.
.nextcheck
inc .checkdata
bne +
inc .checkdata+1
+ sty SCRATCH
ldy #0
lda (.checkdata),y
ldy SCRATCH
ora #0
rts
;;; Print out the sequence of instructions at PCL,PCH, until we hit a JSR.
.printtest
+print
!text "AFTER SEQUENCE",$8D
+printed
-
ldy #0
lda (PCL),y
cmp #$20
beq +++
lda #'-'
jsr COUT
lda #' '
jsr COUT
ldx #0
lda (PCL,x)
jsr $f88e
ldx #3
jsr $f8ea
jsr $f953
sta PCL
sty PCH
lda #$8D
jsr COUT
jmp -
+++ rts
jmp PRINTTEST
;;; Copy zero page to aux mem. Assumes zp pointing at main mem, and leaves it that way.
zptoaux

View File

@ -2,6 +2,8 @@
;;; Copyright © 2016 Zellyn Hunter <zellyn@gmail.com>
!zone langcard {
.checkdata = tmp1
LANGCARDTESTS
lda #0
sta LCRESULT
@ -61,20 +63,25 @@ LANGCARDTESTS_NO_CHECK:
+ lda $C081 ; Read ROM with single access (only one needed to bank out)
lda #$53
cmp $D17B
beq .dotest
beq .datadriventests
+prerr $000E ;; E000E: We tried to put the language card into read ROM, but failed to read.
!text "CANNOT READ FROM ROM"
+prerred
sec
rts
;; Parameterized tests
.dotest lda #<.tests
sta 0
;;; Main data-driven test. PCL,PCH holds the address of the next
;;; data-driven test routine. We expect the various softswitches
;;; to be reset each time we loop at .ddloop.
.datadriventests
lda #<.tests
sta PCL
lda #>.tests
sta 1
.outer
sta PCH
;;; Main data-drive-test loop.
.ddloop
ldy #0
;; Initialize to known state:
;; - $11 in $D17B bank 1 (ROM: $53)
;; - $22 in $D17B bank 2 (ROM: $53)
@ -91,32 +98,25 @@ LANGCARDTESTS_NO_CHECK:
sta $D17B
lda $C080
ldy #0
jmp (PCL) ; Jump to test routine
.inner
lda ($0),y
cmp #$ff
beq .test
tax
bmi +
ora #$80
sta .lda+1
.lda lda $C000
jmp ++
+ sta .sta+1
.sta sta $C000
++ iny
bne .inner
.test ;; ... test the triple
;; Test routine will JSR back to here, so the check data address is on the stack.
.test ;; ... test the quintiple of test values
inc $D17B
inc $FE1F
iny
;; y now points to d17b-current,fe1f-current,bank1,bank2,fe1f-ram test quintiple
;; pull address off of stack: it points just below check data for this test.
pla
sta .checkdata
pla
sta .checkdata+1
;; .checkdata now points to d17b-current,fe1f-current,bank1,bank2,fe1f-ram test quintiple
;; Test current $D17B
lda (0),y
jsr NEXTCHECK
cmp $D17B
beq +
lda $D17B
@ -125,7 +125,7 @@ LANGCARDTESTS_NO_CHECK:
+print
!text "$D17B TO CONTAIN $"
+printed
lda (0),y
jsr CURCHECK
jsr PRBYTE
+print
!text ", GOT $"
@ -136,9 +136,8 @@ LANGCARDTESTS_NO_CHECK:
jsr COUT
jmp .datatesturl
+ iny
;; Test current $FE1F
lda (0),y
+ ;; Test current $FE1F
jsr NEXTCHECK
cmp $FE1F
beq +
lda $FE1F
@ -147,7 +146,7 @@ LANGCARDTESTS_NO_CHECK:
+print
!text "$FE1F=$"
+printed
lda (0),y
jsr CURCHECK
jsr PRBYTE
+print
!text ", GOT $"
@ -158,11 +157,9 @@ LANGCARDTESTS_NO_CHECK:
jsr COUT
jmp .datatesturl
+ iny
;; Test bank 1 $D17B
+ ;; Test bank 1 $D17B
lda $C088
lda (0),y
jsr NEXTCHECK
cmp $D17B
beq +
lda $D17B
@ -171,7 +168,7 @@ LANGCARDTESTS_NO_CHECK:
+print
!text "$D17B IN RAM BANK 1 TO CONTAIN $"
+printed
lda (0),y
jsr CURCHECK
jsr PRBYTE
+print
!text ", GOT $"
@ -182,11 +179,9 @@ LANGCARDTESTS_NO_CHECK:
jsr COUT
jmp .datatesturl
+ iny
;; Test bank 2 $D17B
+ ;; Test bank 2 $D17B
lda $C080
lda (0),y
jsr NEXTCHECK
cmp $D17B
beq +
lda $D17B
@ -195,7 +190,7 @@ LANGCARDTESTS_NO_CHECK:
+print
!text "$D17B IN RAM BANK 2 TO CONTAIN $"
+printed
lda (0),y
jsr CURCHECK
jsr PRBYTE
+print
!text ", GOT $"
@ -206,11 +201,9 @@ LANGCARDTESTS_NO_CHECK:
jsr COUT
jmp .datatesturl
+ iny
;; Test RAM $FE1F
+ ;; Test RAM $FE1F
lda $C080
lda (0),y
jsr NEXTCHECK
cmp $FE1F
beq +
lda $FE1F
@ -219,7 +212,7 @@ LANGCARDTESTS_NO_CHECK:
+print
!text "RAM $FE1F=$"
+printed
lda (0),y
jsr CURCHECK
jsr PRBYTE
+print
!text ", GOT $"
@ -230,19 +223,15 @@ LANGCARDTESTS_NO_CHECK:
jsr COUT
jmp .datatesturl
+ iny
lda ($0),y ; Done with the parameterized tests?
cmp #$ff
+ ;; Jump PCL,PCH up to after the test data, and loop.
jsr NEXTCHECK
bne +
jmp .over
+ clc
tya
adc $0
sta $0
bcc +
inc $1
+ jmp .outer
jmp .success
+ ldx .checkdata
ldy .checkdata+1
stx PCL
sty PCH
jmp .ddloop
.datatesturl
+prerr $0007 ;; E0007: This is a data-driven test of Language Card operation. We initialize $D17B in RAM bank 1 to $11, $D17B in RAM bank 2 to $22, and $FE1F in RAM to $33. Then, we perform a testdata-driven sequence of LDA and STA to the $C08X range. Finally we (try to) increment $D17B and $FE1F. Then we test (a) the current live value in $D17B, (b) the current live value in $FE1F, (c) the RAM bank 1 value of $D17B, (d) the RAM bank 2 value of $D17B, and (e) the RAM value of $FE1F, to see whether they match expected values. $D17B is usually $53 in ROM, and $FE1F is usally $60. For more information on the operation of the language card soft-switches, see Understanding the Apple IIe, by James Fielding Sather, Pg 5-24.
@ -252,79 +241,90 @@ LANGCARDTESTS_NO_CHECK:
rts
.printseq
tya
pha
+print
!text "AFTER SEQUENCE OF:",$8D,"LDA $C080",$8D
!text "AFTER SEQUENCE OF:",$8D,"- LDA $C080",$8D
+printed
ldy #$0
- lda ($0),y
cmp #$ff
beq +++
tax
bmi +
lda #'L'
jsr COUT
lda #'D'
bne ++
+ lda #'S'
jsr COUT
lda #'T'
++ jsr COUT
jsr PRINTTEST
+print
!text "A $C0"
!text "- INC $D17B",$8D,"- INC $FE1F",$8D,"EXPECTED "
+printed
txa
ora #$80
jsr PRBYTE
lda #$8D
jsr COUT
iny
bne -
+++
+print
!text "INC $D17B",$8D,"INC $FE1F",$8D,"EXPECTED "
+printed
pla
tay
rts
.tests
;; Format:
;; - $ff-terminated list of C0XX addresses (0-F to read C08X, 80-8F to write C0XX).
;; Sequence of test instructions, finishing with `jsr .test`.
;; - quint: expected current $d17b and fe1f, then d17b in bank1, d17b in bank 2, and fe1f
;; (All sequences start with lda $C080, just to reset things to a known state.)
!byte $08, $ff ; Read $C088 (RAM read, write protected)
;; 0-byte to terminate tests.
lda $C088 ; Read $C088 (RAM read, write protected)
jsr .test ;
!byte $11, $33, $11, $22, $33 ;
!byte $00, $ff ; Read $C080 (read bank 2, write disabled)
;
lda $C080 ; Read $C080 (read bank 2, write disabled)
jsr .test ;
!byte $22, $33, $11, $22, $33 ;
!byte $01, $ff ; Read $C081 (ROM read, write disabled)
;
lda $C081 ; Read $C081 (ROM read, write disabled)
jsr .test ;
!byte $53, $60, $11, $22, $33 ;
!byte $01, $09, $ff ; Read $C081, $C089 (ROM read, bank 1 write)
;
lda $C081 ; Read $C081, $C089 (ROM read, bank 1 write)
lda $C089 ;
jsr .test ;
!byte $53, $60, $54, $22, $61 ;
!byte $01, $01, $ff ; Read $C081, $C081 (read ROM, write RAM bank 2)
;
lda $C081 ; Read $C081, $C081 (read ROM, write RAM bank 2)
lda $C081 ;
jsr .test ;
!byte $53, $60, $11, $54, $61 ;
!byte $01, $01, $81, $ff ; Read $C081, $C081, write $C081 (read ROM, write RAM bank bank 2)
;
lda $C081 ; Read $C081, $C081, write $C081 (read ROM, write RAM bank bank 2)
lda $C081 ;
sta $C081 ;
jsr .test ;
!byte $53, $60, $11, $54, $61 ; See https://github.com/zellyn/a2audit/issues/3
!byte $0b, $ff ; Read $C08B (read RAM bank 1, no write)
;
lda $C08B ; Read $C08B (read RAM bank 1, no write)
jsr .test ;
!byte $11, $33, $11, $22, $33 ;
!byte $03, $ff ; Read $C083 (read RAM bank 2, no write)
;
lda $C083 ; Read $C083 (read RAM bank 2, no write)
jsr .test ;
!byte $22, $33, $11, $22, $33 ;
!byte $0b, $0b, $ff ; Read $C08B, $C08B (read/write RAM bank 1)
;
lda $C08B ; Read $C08B, $C08B (read/write RAM bank 1)
lda $C08B ;
jsr .test ;
!byte $12, $34, $12, $22, $34 ;
!byte $0f, $07, $ff ; Read $C08F, $C087 (read/write RAM bank 2)
;
lda $C08F ; Read $C08F, $C087 (read/write RAM bank 2)
lda $C087 ;
jsr .test ;
!byte $23, $34, $11, $23, $34 ;
!byte $07, $0D, $ff ; Read $C087, read $C08D (read ROM, write bank 1)
;
lda $C087 ; Read $C087, read $C08D (read ROM, write bank 1)
lda $C08D ;
jsr .test ;
!byte $53, $60, $54, $22, $61 ;
!byte $0b, $8b, $0b, $ff ; Read $C08B, write $C08B, read $C08B (read RAM bank 1, no write)
!byte $11, $33, $11, $22, $33 ; (this one is tricky: reset WRTCOUNT by writing halfway)
!byte $8b, $8b, $0b, $ff ; Write $C08B, write $C08B (read RAM bank 1, no write)
;
lda $C08B ; Read $C08B, write $C08B, read $C08B (read RAM bank 1, no write)
sta $C08B ; (this one is tricky: reset WRTCOUNT by writing halfway)
lda $C08B ;
jsr .test ;
!byte $11, $33, $11, $22, $33 ;
!byte $ff
;
sta $C08B ; Write $C08B, write $C08B, read $C08B (read RAM bank 1, no write)
sta $C08B ;
lda $C08B ;
jsr .test ;
!byte $11, $33, $11, $22, $33 ;
;
!byte 0
nop ; Provide clean break after data when viewing disassembly
nop
.over
.success
;; Success
+print

45
audit/printtest.asm Normal file
View File

@ -0,0 +1,45 @@
;;; Helper routines for printing out sequences of test code.
;;; Copyright © 2017 Zellyn Hunter <zellyn@gmail.com>
!zone printtest {
.checkdata = tmp1
PRINTTEST
-
ldy #0
lda (PCL),y
cmp #$20
beq +++
lda #'-'
jsr COUT
lda #' '
jsr COUT
ldx #0
lda (PCL,x)
jsr $f88e
ldx #3
jsr $f8ea
jsr $f953
sta PCL
sty PCH
lda #$8D
jsr COUT
jmp -
+++ rts
;;; Increment .checkdata pointer to the next memory location, and load
;;; it into the accumulator. X and Y are preserved.
NEXTCHECK
inc .checkdata
bne CURCHECK
inc .checkdata+1
CURCHECK
sty SCRATCH
ldy #0
lda (.checkdata),y
ldy SCRATCH
ora #0
rts
} ;printtest