From 26e75c13b8cf375477d6f75f8b2f58bf339f7701 Mon Sep 17 00:00:00 2001 From: Zellyn Hunter Date: Mon, 9 Jan 2017 21:41:06 -0500 Subject: [PATCH] copied langcard to auxmem tests, other rearranging --- audit/audit.asm | 66 ++++++++- audit/audit.dsk | Bin 143360 -> 143360 bytes audit/auxmem.asm | 303 ++++++++++++++++++++++++++++++++++++++++++ audit/detect.asm | 2 +- audit/langcard.asm | 8 +- audit/shasumtests.asm | 43 ++++++ v0/index.md | 16 +++ 7 files changed, 429 insertions(+), 9 deletions(-) create mode 100644 audit/auxmem.asm diff --git a/audit/audit.asm b/audit/audit.asm index de68411..9978722 100644 --- a/audit/audit.asm +++ b/audit/audit.asm @@ -5,8 +5,12 @@ !to "audit.o", plain * = $6000 + CSW = $36 + KSW = $38 HOME = $FC58 COUT = $FDED + COUT1 = $FDF0 + KEYIN = $FD1B CROUT = $FD8E PRBYTE = $FDDA PRNTYX = $F940 @@ -16,8 +20,10 @@ ;; Printing and error macros. !src "macros.asm" - + main: + jsr standard_fixup + jsr HOME +print !text "APPLE II AUDIT",$8D,$8D @@ -28,10 +34,17 @@ main: ;; Language card tests. jsr LANGCARDTESTS - + + ;; Auxiliary memory card tests. + jsr AUXMEMTESTS + + ;; ROM SHA-1 checks. + ;; jsr SHASUMTESTS - do this later, because it's SLOW! + end: jmp * !src "langcard.asm" + !src "auxmem.asm" !src "shasumtests.asm" print @@ -50,6 +63,21 @@ getch lda $FEED ; FEED gets modified jmp - + rts +;;; Print a string of bytes, as hex. +;;; Address in SRC, count in A. +;;; Burns A,Y. +prbytes: + ldy #0 +- pha + lda (SRC),y + jsr PRBYTE + iny + pla + adc #$ff + bne - + rts + + errora pha lda $C082 @@ -73,15 +101,17 @@ getche lda $FEED ; FEED gets modified beq + jsr COUT jmp - -+ ++ +print !text "ZELLYN.COM/A2AUDIT/V0#E",0 +printed jsr PRNTYX + lda #$8D + jsr COUT rts !src "technote2.asm" !src "../shasum/shasum.asm" - + ; !if * != STRINGS { ; !error "Expected STRINGS to be ", * ; } @@ -90,3 +120,31 @@ rts !error "End of compilation passed STRINGS:", * } +;;; If we loaded via standard delivery, turn the motor off and fix up +;;; CSW and KSW (in case the user typed PR#6 or IN#6 to boot). +standard_fixup: + ;; TODO(zellyn): actually check for standard delivery. + ;; Turn drive motor off - do this regardless, since it doesn't hurt. + ldx $2B + lda $C088,X + + ;; If we typed PR#6 or IN#6 or something similar, the low byte + ;; of CSW or KSW will be 0. + + ;; Fixup CSW + lda CSW + bne + + ;; Point COUT at COUT1 + lda #COUT1 + sta CSW+1 + + ;; Fixup KSW ++ lda KSW + bne + + lda #KEYIN + sta KSW+1 ++ rts diff --git a/audit/audit.dsk b/audit/audit.dsk index fcd95986ae2099ba38edecb16796c5f5726f4afb..999ea2330ad4c21718052f13c67e6c799231c0b0 100644 GIT binary patch delta 2918 zcmcJPe@q+a8OL8^V-5$H+c=9;e)wHfwXEqX)HH-lSwd*4rK+oK(pFVd{&2wNjuurW zAazqTnYD95yWU1}(iGZsdWUeAH{~k4MQLC`vI7P#!S)Nbv#?DX(xfd@7U$YkiV6+c z^PbQA$g)ZMW9a02-tYT)-sgG0?|bwv3cZU$f2*~-Cl>8`&vMH4dff**#`|KCMkY`_ z+(_?+cSo8at`0XryvKL4>(x*vZtKKO^PwYQJC(v^cyA{iUJEa-hC@s4(;YQ1L>(q} zwlD{{0GZ|Z=}tOiN@v$3VoF1+QlTadoiS&~>I^+^N@rH3p`{O&XW-9A4;M7bdw>oG zolOzp@6BO5)OAPf9Rfs;bwc1S1}-DO2&RP&TUfZll7sul4@>XYNLQS9NC^2}xx$vP z`s$z)2YE<~9ic+0!BTL8uWbw4i%Z<{{bcF*GPq^znVKG~+dDKt%{}AiJ6D0nI=%T< zHl&9Bd+u67(Nwc0uXTRapY^qhz)Ndop##%X462z{*r)P^-CZut#G08Cw|6MDW!pl= zs1!y7#hUboDH^CTq)!dWd!U1qjk=_P?@E2nJ0SVU=20XKoZ&-)==bG|5`9A+mFN%U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it/auxmem.asm new file mode 100644 index 0000000..726fd1e --- /dev/null +++ b/audit/auxmem.asm @@ -0,0 +1,303 @@ +;;; Apple IIe Auxiliary memory audit routines +;;; Copyright © 2017 Zellyn Hunter + + !zone auxmem { +AUXMEMTESTS + lda MEMORY + cmp #65 + bcs + + +print + !text "64K OR LESS:SKIPPING AUXMEM TEST",$8D + +printed + rts + ;; Setup - store differing values in bank first and second banked areas. ++ lda $C08B ; Read and write bank 1 + lda $C08B + lda #$11 + sta $D17B ; $D17B is $53 in Apple II/plus/e/enhanced + cmp $D17B + beq + + +prerr $0007 ;; E0007: We tried to put the language card into read bank 1, write bank 1, but failed to write. + !text "CANNOT WRITE TO LC BANK 1 RAM" + +prerred + rts + lda #$33 ++ sta $FE1F ; FE1F is $60 in Apple II/plus/e/enhanced + cmp $FE1F + beq .dotest + +prerr $0008 ;; E0008: We tried to put the language card into read RAM, write RAM, but failed to write. + !text "CANNOT WRITE TO LC RAM" + +prerred + rts ++ lda $C083 ; Read and write bank 2 + lda $C083 + lda #$22 + sta $D17B + cmp $D17B + beq + + +prerr $0009 ;; E0009: We tried to put the language card into read bank 2, write bank 2, but failed to write. + !text "CANNOT WRITE TO LC BANK 2 RAM" + +prerred + rts + + ;; Parameterized tests + +.dotest lda #<.tests + sta 0 + lda #>.tests + sta 1 +.outer + ;; Initialize to known state: + ;; - $11 in $D17B bank 1 (ROM: $53) + ;; - $22 in $D17B bank 2 (ROM: $53) + ;; - $33 in $FE1F (ROM: $60) + lda $C08B ; Read and write bank 1 + lda $C08B + lda #$11 + sta $D17B + lda #$33 + sta $FE1F + lda $C083 ; Read and write bank 2 + lda $C083 + lda #$22 + sta $D17B + lda $C080 + + ldy #0 + +.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 + inc $D17B + inc $FE1F + iny + + ;; y now points to d17b-current,fe1f-current,bank1,bank2,fe1f-ram test quintiple + + ;; Test current $D17B + lda (0),y + cmp $D17B + beq + + lda $D17B + pha + jsr .printseq + +print + !text "$D17B TO CONTAIN $" + +printed + lda (0),y + jsr PRBYTE + +print + !text ", GOT $" + +printed + pla + jsr PRBYTE + lda #$8D + jsr COUT + jmp .datatesturl + ++ iny + ;; Test current $FE1F + lda (0),y + cmp $FE1F + beq + + lda $FE1F + pha + jsr .printseq + +print + !text "$FE1F=$" + +printed + lda (0),y + jsr PRBYTE + +print + !text ", GOT $" + +printed + pla + jsr PRBYTE + lda #$8D + jsr COUT + jmp .datatesturl + ++ iny + + ;; Test bank 1 $D17B + lda $C088 + lda (0),y + cmp $D17B + beq + + lda $D17B + pha + jsr .printseq + +print + !text "$D17B IN RAM BANK 1 TO CONTAIN $" + +printed + lda (0),y + jsr PRBYTE + +print + !text ", GOT $" + +printed + pla + jsr PRBYTE + lda #$8D + jsr COUT + jmp .datatesturl + ++ iny + + ;; Test bank 2 $D17B + lda $C080 + lda (0),y + cmp $D17B + beq + + lda $D17B + pha + jsr .printseq + +print + !text "$D17B IN RAM BANK 2 TO CONTAIN $" + +printed + lda (0),y + jsr PRBYTE + +print + !text ", GOT $" + +printed + pla + jsr PRBYTE + lda #$8D + jsr COUT + jmp .datatesturl + ++ iny + + ;; Test RAM $FE1F + lda $C080 + lda (0),y + cmp $FE1F + beq + + lda $FE1F + pha + jsr .printseq + +print + !text "RAM $FE1F=$" + +printed + lda (0),y + jsr PRBYTE + +print + !text ", GOT $" + +printed + pla + jsr PRBYTE + lda #$8D + jsr COUT + jmp .datatesturl + ++ iny + + lda ($0),y ; Done with the parameterized tests? + cmp #$ff + bne + + jmp .over ++ clc + tya + adc $0 + sta $0 + bcc + + inc $1 ++ jmp .outer + +.datatesturl + +prerr $000A ;; E000A: 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. + !text "DATA-DRIVEN TEST FAILED" + +prerred + rts + +.printseq + tya + pha + +print + !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 + +print + !text "A $C0" + +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). + ;; - 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) + !byte $11, $33, $11, $22, $33 ; + !byte $00, $ff ; Read $C080 (read bank 2, write disabled) + !byte $22, $33, $11, $22, $33 ; + !byte $01, $ff ; Read $C081 (ROM read, write disabled) + !byte $53, $60, $11, $22, $33 ; + !byte $01, $09, $ff ; Read $C081, $C089 (ROM read, bank 1 write) + !byte $53, $60, $54, $22, $61 ; + !byte $01, $01, $ff ; Read $C081, $C081 (read ROM, write RAM bank 2) + !byte $53, $60, $11, $54, $61 ; + !byte $0b, $ff ; Read $C08B (read RAM bank 1, no write) + !byte $11, $33, $11, $22, $33 ; + !byte $03, $ff ; Read $C083 (read RAM bank 2, no write) + !byte $22, $33, $11, $22, $33 ; + !byte $0b, $0b, $ff ; Read $C08B, $C08B (read/write RAM bank 1) + !byte $12, $34, $12, $22, $34 ; + !byte $0f, $07, $ff ; Read $C08F, $C087 (read/write RAM bank 2) + !byte $23, $34, $11, $23, $34 ; + !byte $07, $0D, $ff ; Read $C087, read $C08D (read ROM, write bank 1) + !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 $ff + + nop ; Provide clean break after data when viewing disassembly + nop + nop +.over + + ;; Success + +print + !text "LANGUAGE CARD TESTS SUCCEEDED",$8D + +printed +.done + rts + } ;auxmem diff --git a/audit/detect.asm b/audit/detect.asm index b07e411..b507b08 100644 --- a/audit/detect.asm +++ b/audit/detect.asm @@ -85,7 +85,7 @@ !text "PLAIN APPLE II",$8D +printed beq .done -.iiplus +.iiplus +print !text "APPLE II PLUS",$8D +printed diff --git a/audit/langcard.asm b/audit/langcard.asm index b634c7c..3cd8266 100644 --- a/audit/langcard.asm +++ b/audit/langcard.asm @@ -107,7 +107,7 @@ LANGCARDTESTS lda #$8D jsr COUT jmp .datatesturl - + + iny ;; Test current $FE1F lda (0),y @@ -129,7 +129,7 @@ LANGCARDTESTS lda #$8D jsr COUT jmp .datatesturl - + + iny ;; Test bank 1 $D17B @@ -153,7 +153,7 @@ LANGCARDTESTS lda #$8D jsr COUT jmp .datatesturl - + + iny ;; Test bank 2 $D17B @@ -221,7 +221,7 @@ LANGCARDTESTS !text "DATA-DRIVEN TEST FAILED" +prerred rts - + .printseq tya pha diff --git a/audit/shasumtests.asm b/audit/shasumtests.asm index e176087..1af2dd5 100644 --- a/audit/shasumtests.asm +++ b/audit/shasumtests.asm @@ -2,7 +2,50 @@ ;;; Copyright © 2016 Zellyn Hunter !zone shasumtests { + + !addr SRC = $06 + !addr DST = $08 + !addr SHAINPUT = $eb + !addr SHALENGTH = $ee + SHASUMTESTS + + +print + !text "COMPUTING ROM SHASUM",$8D + +printed + + lda #0 + sta SHAINPUT + lda #$E0 + sta SHAINPUT+1 + lda #0 + sta SHALENGTH + lda #$20 + sta SHALENGTH+1 + jsr SHASUM + + +print + !text "SHASUM:",$8D + +printed + + lda #SHA + sta SRC+1 + lda #SHALEN + jsr prbytes + .done + rts } ;shasumtests + + !eof + + 2744ebe53a13578f318fe017d01ea6a975083250 + +Apple II: 102FBF7DEA8B8D6DE5DE1C484FF45E7B5DFB28D5 (oe, vii) +Apple II Plus: 5a23616dca14e59b4aca8ff6cfa0d98592a78a79 (oe, mame) + 2744ebe53a13578f318fe017d01ea6a975083250 (vii) +Apple IIe: 8895a4b703f2184b673078f411f4089889b61c54 (mame) +Apple IIe (enhanced): afb09bb96038232dc757d40c0605623cae38088e (vii, mame) diff --git a/v0/index.md b/v0/index.md index 7455619..1f480b3 100644 --- a/v0/index.md +++ b/v0/index.md @@ -23,3 +23,19 @@ We tried to put the language card into read bank 2, write bank 2, but failed to ## E0006 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. + +## E0007 + +We tried to put the language card into read bank 1, write bank 1, but failed to write. + +## E0008 + +We tried to put the language card into read RAM, write RAM, but failed to write. + +## E0009 + +We tried to put the language card into read bank 2, write bank 2, but failed to write. + +## E000A + +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.