From cde7393fb5397a3ab6408d41efb0bc8a6ccbd291 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Tue, 29 Sep 2015 09:14:10 -0500 Subject: [PATCH] Separated ilen and ilen testing, switching to text variants of AppleScript. --- online/Makefile | 11 +-- online/ilen.asm | 128 -------------------------- online/online.asm | 2 +- online/test.scpt | Bin 7030 -> 0 bytes online/test.scpt.txt | 49 ++++++++++ shared/Makefile | 17 ++++ shared/ilen-test.asm | 83 +++++++++++++++++ {online => shared}/ilen-test.scpt.txt | 1 - shared/ilen.asm | 51 ++++++++++ 9 files changed, 203 insertions(+), 139 deletions(-) delete mode 100644 online/ilen.asm delete mode 100644 online/test.scpt create mode 100644 online/test.scpt.txt create mode 100755 shared/Makefile create mode 100644 shared/ilen-test.asm rename {online => shared}/ilen-test.scpt.txt (97%) create mode 100644 shared/ilen.asm 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 b5f14330979cb1a4b0a8ac0bc085e558b088ae39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7030 zcmcIpd3;pW_5Z$?5aJDYU=SgS;)BW-Az^W=RVhMPS|GmyK@n+vnLLsqlbK;=5-$p)r+Mqxa*ipYR4{cGX z3Gzm>k3ac04wHW=qT*85Ys@6vWHR0mivbt0_d1mDr*Rmpgc;58|16S!qHqB6-Be8@ zV9UP@-@+_k%Ym|?NV^E_G=ZJ+rxkEaNE6s`|2rS;(Loc~C-B=szWgu3iXdM_5>?YR z!m#Su!;Lrw@w{!t|VXdwh?=lURjFOt6_GyrX)^=^%aHlxQ59a(Op9cgvM z;hG>Xh61Xft?WZ59AOc$w-d@SB<*D!f4q}PI6cZL(_SiFmP%BWx#{|{DmNXC^iR)D zXT19Uk^1VgL_8Lads$SPO!P1+4dDn_E6_QN&X|WZJY?WtG{#~mMv{la?*w5Fl%dk^ zPZ5?O#nvifmtXb7Remjs2>P>SHcN)I>iHERtmcRW;)o$i=m7DwASn!}Dk zH%;JMP!T%FpXE>TosvJ(g6gB`h#Sc?8VeG+2qM?P)GhgwF_rHOr*16A!qEgii7<|m zKcYK&D5B!hNFwD$Vu^H)1i0_C2#)U#YY-(1qmz8A$b349yv%1STv)&x{l8+0YzKJu09 z)#wul$`<)jeviINzRU@l@?z$MP%Qp(YyCZFUwtXn9+b!ziYQ;zB_c76l0YhIP(D}k zIopRuqh5i0VfNuG1NNHJ)VtZ5e^(^GL-7EpOs!Y%Mrvtretm3Ex6za9I9_&Z93O04 zPi|B{^w$Lb#`U$jq0~kxhm~P~Ch(Wrmn{P^NE7%6tuIC0rDPWsH6iJxSq5tif;Euq zDnWnQsbnX`WxHo%0ErF837Wv)!ZMsJpW#H=p@@o0Cq<`DDW4w6wA{ksUSm|_#NfP_ zVX%CPlN3R|3VKco#GptxI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IQ1u9Eh_TZ^|=Do-va9QQZ;}y9Kvu0^cImV2wPDrMS%^;x;bj8!6;W^wJrB z(|G%I=M0+sZARYP!?>N#1BZ8_xe3gc2*oCKALG=Z=GHTW3!;{i=zpG*C(!3TH{%QOKO+=ky<@Q|#KCp8`l4jEhI2|O&1 zE28Y{C!X<|9~B+4PwEHIEQ*eZ|a2`6bh(ERFnq(~k?n*p$xHL!6X%W`>G)A;?fvyD%R$MCp3 zgeNpB{@K}vuka*RXafIe!6JDu$4}GJ z{o}Wdlb)3a-%?Zdz2Zmg2K6j75z z6AuhaR|OL7!w+~hgjbD3uZ8g%Ip!of1Ln_Rs6UiJ@)*`mGk><+Ww!PemeqJ&6Zk$~ ztOB_cZ^#{rsEP5g0~x;&Fc!UqT zHbvAL>34k69Ivo8gtdnByJ5T=kiN~3ew$?-)@uTvbbG6_EX8|rt0HQR^m_s6_Etx1 z2w{UE{eGAy%9r|9LwY^SM!7{}V?er#)lF{3Cb>xwHIY8Z17TA@x{GxbHixj;klqsJ zap#8LWWX&3JZ!eUe_;1L(My&T$&%Jy_p;ke=o;vnnLBK4kFD0$LLR99=bw4AbCcl4 zqG?0gYNR5pc1$xwTpa2w4>bX=4BoHIx!x!@$YM)wG~Vt80~VW+ zAF_NT*K2&#Jn}lZR<5y_b>pCG4Y zZ|XhZCJf7btNYzM>&nVERqXC)buO9S4tW(NpZEV_PploQR=Wt7eCwiP8OI!6;i40pkEk#-I`gZG|K*~X_(*;qmBn4N_~enQCxp7Mo=rSy|aWL~p|jaYqi_@% 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 + +