Separated ilen and ilen testing, switching to text variants of AppleScript.

This commit is contained in:
Rob Greene 2015-09-29 09:14:10 -05:00
parent 745c7f5bba
commit cde7393fb5
9 changed files with 203 additions and 139 deletions

View File

@ -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

View File

@ -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
; <sp><sp><sp>XX<sp>...XX<cr>
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

View File

@ -184,7 +184,7 @@ printz:
pha
rts
.include "ilen.asm"
.include "../shared/ilen.asm"
; =======================================

Binary file not shown.

49
online/test.scpt.txt Normal file
View File

@ -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

17
shared/Makefile Executable file
View File

@ -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

83
shared/ilen-test.asm Normal file
View File

@ -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
; <sp><sp><sp>XX<sp>...XX<cr>
updnborder:
jsr spout
jsr spout
jsr spout
ldy #0
: tya
jsr prbyte
jsr spout
iny
cpy #$10
bcc :-
jmp crout
; <sp><sp><sp>--<sp>...--<cr>
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"

View File

@ -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", ¬

51
shared/ilen.asm Normal file
View File

@ -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