Extracted ilen proc, added unit test, and AppleScript to execute.

This commit is contained in:
Rob Greene 2015-09-28 23:30:49 -05:00
parent bd38153545
commit a1f27f87e5
3 changed files with 220 additions and 1 deletions

View File

@ -5,14 +5,25 @@ 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:
#$(VIRTUAL2) ./online.po
osascript test.scpt "$(PWD)/online.po"
run:
$(VIRTUAL2) ./online.po
clean:
rm *.bin *.lst *.o online.po

80
online/ilen-test.scpt.txt Normal file
View File

@ -0,0 +1,80 @@
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", ¬
" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --", ¬
"00|01 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|0F", ¬
"10|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|1F", ¬
"20|03 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|2F", ¬
"30|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|3F", ¬
"40|01 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|4F", ¬
"50|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|5F", ¬
"60|01 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|6F", ¬
"70|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|7F", ¬
"80|02 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|8F", ¬
"90|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|9F", ¬
"A0|02 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|AF", ¬
"B0|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|BF", ¬
"C0|02 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|CF", ¬
"D0|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|DF", ¬
"E0|02 02 02 02 02 02 02 02 01 02 01 01 03 03 03 03|EF", ¬
"F0|02 02 02 02 02 02 02 02 01 03 01 01 03 03 03 03|FF", ¬
" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --", ¬
" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F" ¬
}
tell application "Virtual ]["
activate
close every machine saving no
set theMachine to (make new AppleIIe)
tell theMachine
eject device "S6D1"
insert IMAGE into device "S6D1"
delay 0.5
restart
set speed to maximum
delay 0.25
-- Load the ILEN.TEST program
type line "-ILEN.TEST"
-- 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!
set linesout to (count lines of compact screen text) - 1
set matches to true
set failmessage to ""
repeat with j from 1 to count(expected)
set a to line (linesout - j + 1) of compact screen text
set e to item ((count of expected) - j + 1) of expected
if a is not equal to e
set matches to false
set failmessage to failmessage & " " & j
display dialog "Mismatch:\nA=[" & a & "]\nE=[" & e & "]\n" ¬
buttons {"OK"} default button 1
end if
end repeat
if matches then
type line "REM *** SUCCESS ***"
else
type text "REM >>> FAIL <<<"
type ctrl "G"
type ctrl "G"
type ctrl "G"
type text failmessage
end if
end tell
end tell
end run

128
online/ilen.asm Normal file
View File

@ -0,0 +1,128 @@
;
; 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