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

@ -24,8 +24,8 @@
.region = tmp4
.actual = tmp1
.desired = tmp2
AUXMEMTESTS
lda #0
sta AUXRESULT
@ -55,7 +55,7 @@ AUXMEMTESTS
sta LCRESULT1
lda #0
sta LCRESULT
;; Store distinct values in RAM areas, to see if they stay safe.
lda $C08B ; Read and write bank 1
lda $C08B
@ -68,7 +68,7 @@ AUXMEMTESTS
sta $D17B
jsr zptoaux
sta SET_ALTZP
jsr LANGCARDTESTS_NO_CHECK
sta RESET_ALTZP
@ -83,7 +83,7 @@ AUXMEMTESTS
+prerred
sec
rts
;; Check that the stuff we stashed in main RAM was unaffected.
+
lda $C088 ; Read bank 1
@ -147,7 +147,7 @@ AUXMEMTESTS
lda #>.auxtests
sta PCH
;;; Main data-drive-test loop.
.ddloop
.ddloop
ldy #0
lda (PCL),Y
beq .success
@ -171,7 +171,7 @@ AUXMEMTESTS
sta RESET_ALTZP
sta RESET_RAMWRT
sta RESET_RAMRD
sec
sbc #2
bcs .initloop
@ -205,7 +205,7 @@ AUXMEMTESTS
sta .checkdata+1
;; First checkdata byte is for Cxxx tests.
jsr .nextcheck
jsr NEXTCHECK
bmi +
jsr .checkCxxx
@ -214,11 +214,11 @@ AUXMEMTESTS
jsr RESETALL
stx .checkdata
sty .checkdata+1
;; 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
@ -257,7 +257,7 @@ AUXMEMTESTS
sty .checkdata+1
sta .ismain
jmp .checkloop
.checkdone
;; Jump PCL,PCH to next test, and loop.
ldx .checkdata
@ -285,7 +285,7 @@ AUXMEMTESTS
;; X = index of memory location
;; A = actual
;; Y = desired | (high bit set if main, unset=aux)
jsr RESETALL
sta .actual
@ -330,10 +330,10 @@ AUXMEMTESTS
+prerr $000A ;; E000A: This is a data-driven test of main and auxiliary memory softswitch operation. We initialize $FF, $100, $200, $3FF, $427, $7FF, $800, $1FFF, $2000, $3FFF, $4000, $5FFF, and $BFFF in main RAM to value 1, and in auxiliary RAM to value 3. Then, we perform a testdata-driven sequence of instructions. Finally we (try to) increment all test locations. Then we test the expected values of the test locations in main and auxiliary memory. For more information on the operation of the auxiliary memory soft-switches, see Understanding the Apple IIe, by James Fielding Sather, Pg 5-22 to 5-28.
!text "FOLLOWED BY INC OF TEST LOCATIONS. SEE"
+prerred
sec
rts
;;; Check that the expected ROM areas are visible.
.checkCxxx
.gotCxxx = tmp0
@ -367,7 +367,7 @@ AUXMEMTESTS
+printed
lda .gotCxxx
jsr .printCxxxBits
+prerr $000B ;; E000B: This is a the Cxxx-ROM check part of the auxiliary memory data-driven test (see E000A for a description of the other part). After a full reset, we perform a testdata-driven sequence of instructions. Finally we check which parts of Cxxx ROM seem to be visible. We check C100-C2FF, C300-C3FF, C400-C7FF (which should be the same as C100-C2FF), and C800-CFFE. For more details, see Understanding the Apple IIe, by James Fielding Sather, Pg 5-28.
!text "CXXX ROM TEST FAILED"
+prerred
@ -377,7 +377,7 @@ AUXMEMTESTS
pla
sec
rts
.checkCxxxDone
rts
@ -462,47 +462,14 @@ AUXMEMTESTS
!text "ROM",$8D
+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
ldx #0
@ -529,7 +496,7 @@ zpfromaux
.auxtests
;; Our four basic tests --------------------------------------
;; Test 1: everything reset.
lda #1
jsr .check
@ -546,7 +513,7 @@ zpfromaux
sta SET_RAMRD
jsr .check
!byte .C_skip, 2, 4, 4, 4, 3, 3, 3, 3
;; Test 4: write to AUX, read from AUX, everything else normal.
lda #4
sta SET_RAMRD
@ -556,7 +523,7 @@ zpfromaux
;; Our four basic tests, but with 80STORE ON -----------------
;; (400-7ff is pointing at main mem)
;; Test 5: everything reset.
lda #5
sta SET_80STORE
@ -576,7 +543,7 @@ zpfromaux
sta SET_80STORE
jsr .check
!byte .C_skip, 2, 4, 2, 4, 3, 3, 3, 3
;; Test 8: read and write aux
lda #8
sta SET_RAMRD
@ -587,7 +554,7 @@ zpfromaux
;; Our four basic tests, but with 80STORE and PAGE2 ON -------
;; (400-7ff is pointing at aux mem)
;; Test 9: everything reset.
lda #9
sta SET_80STORE
@ -610,7 +577,7 @@ zpfromaux
sta SET_PAGE2
jsr .check
!byte .C_skip, 2, 4, 1, 4, 3, 3, 4, 3
;; Test C: read and write aux
lda #$c
sta SET_RAMRD
@ -622,7 +589,7 @@ zpfromaux
;; Our four basic tests, but with 80STORE and HIRES ON -------
;; (400-7ff and 2000-3fff are pointing at main mem)
;; Test D: everything reset.
lda #$d
sta SET_80STORE
@ -645,7 +612,7 @@ zpfromaux
sta SET_HIRES
jsr .check
!byte .C_skip, 2, 4, 2, 2, 3, 3, 3, 3
;; Test 10: read and write aux
lda #$10
sta SET_RAMRD
@ -683,7 +650,7 @@ zpfromaux
sta SET_PAGE2
jsr .check
!byte .C_skip, 2, 4, 1, 1, 3, 3, 4, 4
;; Test 14: read and write aux
lda #$14
sta SET_RAMRD

View File

@ -1,7 +1,9 @@
;;; Apple II Language Card audit routines
;;; Copyright © 2016 Zellyn Hunter <zellyn@gmail.com>
!zone langcard {
!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