diff --git a/online/Makefile b/online/Makefile index c19234d..944e939 100755 --- a/online/Makefile +++ b/online/Makefile @@ -6,24 +6,17 @@ VIRTUAL2 = /Applications/Virtual\ \]\[/Virtual\ \]\[.app/Contents/MacOS/Virtual\ all: online.bin online: online.bin -ilen: ilen.bin online.bin: online.asm cl65 -o online.bin -t none --start-addr 0x2000 -l online.asm cp $(TEMPLATE) online.po $(JAVA) -jar $(AC) -p online.po online BIN 0x2000 < online.bin -ilen.bin: ilen.asm - cl65 --asm-define TESTILEN -o ilen-test.bin -t none --start-addr 0x2000 -l ilen.asm - cp $(TEMPLATE) ilen-test.po - $(JAVA) -jar $(AC) -p ilen-test.po ilen.test BIN 0x2000 < ilen-test.bin - osascript ilen-test.scpt.txt "$(PWD)/ilen-test.po" - test: - osascript test.scpt "$(PWD)/online.po" + osascript test.scpt.txt "$(PWD)/online.po" run: $(VIRTUAL2) ./online.po clean: - rm *.bin *.lst *.o online.po + rm -f *.bin *.lst *.o online.po diff --git a/online/ilen.asm b/online/ilen.asm deleted file mode 100644 index da99076..0000000 --- a/online/ilen.asm +++ /dev/null @@ -1,128 +0,0 @@ -; -; ilen.asm -; - - .PC02 ; Enable 65C02 instructions - - .code - -.ifdef TESTILEN - -crout = $fd8e -cout = $fded -prbyte = $fdda - - .org $2000 - -.proc ilentest - jsr $c300 ; Assume we have an 80 column card available - jsr crout - jsr updnborder - jsr updndividor -; Results -- - ldx #0 -: txa - jsr prbyte - lda #'|'|$80 - jsr cout - ldy #16 -: txa - jsr ilen - jsr prbyte - jsr spout - inx - dey - bne :- - lda #$88 ; (backspace) - jsr cout - lda #'|'|$80 - jsr cout - txa - dec ; we're one past the last one - jsr prbyte - jsr crout - cpx #0 - bne :-- - jsr updndividor - -; XX...XX -updnborder: - jsr spout - jsr spout - jsr spout -; Top line -- - ldy #0 -: tya - jsr prbyte - jsr spout - iny - cpy #$10 - bcc :- - jmp crout - -updndividor: - jsr spout - jsr spout - jsr spout - ldy #0 -; Hypens -: lda #'-'|$80 - jsr cout - jsr cout - jsr spout - iny - cpy #$10 - bcc :- - jmp crout - -spout: - lda #' '|$80 - jmp cout -.endproc -.endif - -; -; Calculate Instruction Length -; Based on observations in 65C02 data sheet: -; * Generally, length is based on LOW nibble -; * There are a few special cases (including X9 column) -; Input: Acc. = instruction -; Output: Acc. = length -.proc ilen - bit #$0f - bne @normal -@column0: - bit #%10010000 ; Normal instructions have at least one of these bits set - beq @notnormal ; None are set -@normal: ; "Normal" values for ALL columns 0-F - asl - asl - asl -@column9: - cmp #$C8 ; xxx11001<<3 (special case for $X9 column) - beq @three - cmp #$48 ; xxx01001<<3 (special case for $X9 column) - beq @two -;@morenormal: - asl - bpl @two ; xxxx0xxx<<4 - asl - bpl @one ; xxxx10xx<<5 - ; fall through for xxxx11xx<<5 -@three: - lda #3 - rts - -@notnormal: - cmp #$20 ; JSR ($20) - beq @three - ; fall through for BRK ($00) / RTI ($40) / RTS ($60) -@one: - lda #1 - rts -@two: - lda #2 - rts -.endproc - - diff --git a/online/online.asm b/online/online.asm index f96b515..3f59368 100644 --- a/online/online.asm +++ b/online/online.asm @@ -184,7 +184,7 @@ printz: pha rts - .include "ilen.asm" + .include "../shared/ilen.asm" ; ======================================= diff --git a/online/test.scpt b/online/test.scpt deleted file mode 100644 index b5f1433..0000000 Binary files a/online/test.scpt and /dev/null differ diff --git a/online/test.scpt.txt b/online/test.scpt.txt new file mode 100644 index 0000000..d19199c --- /dev/null +++ b/online/test.scpt.txt @@ -0,0 +1,49 @@ +on run argv + set IMAGE to item 1 of argv + #set IMAGE to "/Users/rob/asm/basic-system-cmd/online/online.po" + + tell application "Virtual ][" + activate + close every machine saving no + set theMachine to (make new AppleIIe) + tell theMachine + set speed to maximum + eject device "S6D1" + insert IMAGE into device "S6D1" + delay 0.5 + restart + delay 0.25 + -- Load the ONLINE command handler + type line "-ONLINE" + -- Run all legit sequences of ONLINE command (which also exposes a bug) + type line "ONLINE" + type line "ONLINE,S3,D1" + type line "ONLINE,S3,D2" + type line "ONLINE,S6,D1" + type line "ONLINE,S6,D2" + type line "ONLINE" + -- Wait till we have the Applesoft prompt back, then continue + repeat + delay 1.0 -- Let virtual machine go for a second + if the last line of compact screen text = "]" then + exit repeat + end if + end repeat + set speed to regular + -- Test for bug! + --display dialog (count lines of compact screen text) + set i to (count lines of compact screen text) - 1 + if line i of the compact screen text = "S3,D2 ERR=$27" then + type line "REM *** SUCCESS ***" + else + type text "REM >>> FAIL <<<" + type ctrl "G" + type ctrl "G" + type ctrl "G" + type line "" + end if + end tell + end tell +end run + + diff --git a/shared/Makefile b/shared/Makefile new file mode 100755 index 0000000..302cb77 --- /dev/null +++ b/shared/Makefile @@ -0,0 +1,17 @@ +JAVA = java +AC = /Applications/AppleCommander.app/Contents/Resources/Java/AppleCommander.jar +TEMPLATE = ../shared/template.po +VIRTUAL2 = /Applications/Virtual\ \]\[/Virtual\ \]\[.app/Contents/MacOS/Virtual\ \]\[ + +all: + @echo "Please select a target." + +ilen-test.bin: ilen-test.asm + cl65 -o ilen-test.bin -t none --start-addr 0x2000 -l ilen-test.asm + cp $(TEMPLATE) ilen-test.po + $(JAVA) -jar $(AC) -p ilen-test.po ilen.test BIN 0x2000 < ilen-test.bin + osascript ilen-test.scpt.txt "$(PWD)/ilen-test.po" + +clean: + rm -f *.bin *.lst *.o + find . -name "*.po" -not -name "template.po" -print0 | xargs -0 rm -f diff --git a/shared/ilen-test.asm b/shared/ilen-test.asm new file mode 100644 index 0000000..111f4c6 --- /dev/null +++ b/shared/ilen-test.asm @@ -0,0 +1,83 @@ +; +; ilen-test.asm +; +; Semi automated unit test to verify calculated instruction length. +; This is paired with the AppleScript program to check for expected results. +; + + .PC02 ; Enable 65C02 instructions + + .code + +crout = $fd8e +cout = $fded +prbyte = $fdda + + .org $2000 + +.proc ilentest + jsr $c300 ; Assume we have an 80 column card available + jsr crout + jsr updnborder + jsr updndividor +; Results -- + ldx #0 +: txa + jsr prbyte + lda #'|'|$80 + jsr cout + ldy #16 +: txa + jsr ilen + jsr prbyte + jsr spout + inx + dey + bne :- + lda #$88 ; (backspace) + jsr cout + lda #'|'|$80 + jsr cout + txa + dec ; we're one past the last one + jsr prbyte + jsr crout + cpx #0 + bne :-- + jsr updndividor + +; XX...XX +updnborder: + jsr spout + jsr spout + jsr spout + ldy #0 +: tya + jsr prbyte + jsr spout + iny + cpy #$10 + bcc :- + jmp crout + +; --...-- +updndividor: + jsr spout + jsr spout + jsr spout + ldy #0 +: lda #'-'|$80 + jsr cout + jsr cout + jsr spout + iny + cpy #$10 + bcc :- + jmp crout + +spout: + lda #' '|$80 + jmp cout +.endproc + + .include "ilen.asm" diff --git a/online/ilen-test.scpt.txt b/shared/ilen-test.scpt.txt similarity index 97% rename from online/ilen-test.scpt.txt rename to shared/ilen-test.scpt.txt index 4706fe2..e7f20f1 100644 --- a/online/ilen-test.scpt.txt +++ b/shared/ilen-test.scpt.txt @@ -1,6 +1,5 @@ on run argv set IMAGE to item 1 of argv - #set IMAGE to "/Users/rob/asm/basic-system-cmd/online/ilen-test.po" set expected to { ¬ " 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F", ¬ diff --git a/shared/ilen.asm b/shared/ilen.asm new file mode 100644 index 0000000..e414ee6 --- /dev/null +++ b/shared/ilen.asm @@ -0,0 +1,51 @@ +; +; ilen.asm +; + + .PC02 ; Enable 65C02 instructions + +; +; Calculate Instruction Length +; Based on observations in 65C02 data sheet: +; * Generally, length is based on LOW nibble +; * There are a few special cases (including X9 column) +; Input: Acc. = instruction +; Output: Acc. = length +; +.proc ilen + bit #$0f + bne @notcol0 +@column0: + bit #%10010000 ; Normal instructions have at least one of these bits set + beq @notnormal ; None are set +@notcol0: ; "Normal" values for ALL columns 0-F + asl + asl + asl +@column9: + cmp #$C8 ; xxx11001<<3 (special case for $X9 column) + beq @three + cmp #$48 ; xxx01001<<3 (special case for $X9 column) + beq @two + asl + bpl @two ; xxxx0xxx<<4 + asl + bpl @one ; xxxx10xx<<5 + ; fall through for xxxx11xx<<5 +@three: + lda #3 + rts + +@notnormal: + cmp #$20 ; JSR ($20) + beq @three + ; fall through for BRK ($00) / RTI ($40) / RTS ($60) +@one: + lda #1 + rts +@two: + lda #2 + rts +.endproc + +