Ported remaining examples to new simplified Console device
This commit is contained in:
parent
d3aaf705f3
commit
358a902c16
|
@ -1,12 +1,12 @@
|
||||||
( dev/console )
|
( dev/console )
|
||||||
|
|
||||||
%RTN { JMP2r }
|
%RTN { JMP2r }
|
||||||
%PRINT { .Console/string DEO2 }
|
%PRINT { ;print JSR2 }
|
||||||
%BR { #0a .Console/char DEO }
|
%BR { #0a .Console/write DEO }
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|
|10 @Console [ &pad $8 &write $1 ]
|
||||||
|
|
||||||
( variables )
|
( variables )
|
||||||
|
|
||||||
|
@ -18,46 +18,51 @@
|
||||||
|
|
||||||
|0100 ( -> )
|
|0100 ( -> )
|
||||||
|
|
||||||
;char-txt PRINT #42 .Console/char DEO BR
|
;char-txt PRINT #42 .Console/write DEO BR
|
||||||
;byte-txt PRINT #ab .Console/byte DEO BR
|
;byte-txt PRINT #ab ;print-byte JSR2 BR
|
||||||
;short-txt PRINT #cdef .Console/short DEO2 BR
|
;short-txt PRINT #cdef ;print-short JSR2 BR
|
||||||
;string-txt PRINT ;hello-word .Console/string DEO2 BR
|
;string-txt PRINT ;hello-word ;print JSR2 BR
|
||||||
|
|
||||||
;hello-word ;print JSR2
|
;hello-word ;print JSR2
|
||||||
#ffff ;print-hexadecimal JSR2
|
#ffff ;print-short JSR2
|
||||||
;is-word ;print JSR2
|
;is-word ;print JSR2
|
||||||
#ffff ;print-decimal JSR2
|
#ffff ;print-short-decimal JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@print ( addr -- )
|
@print ( addr* -- )
|
||||||
|
|
||||||
&loop
|
&loop
|
||||||
( send ) DUP2 LDA .Console/char DEO
|
( send ) DUP2 LDA .Console/write DEO
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 LDA ,&loop JCN
|
( loop ) DUP2 LDA ,&loop JCN
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@print-hexadecimal ( short -- )
|
@print-short ( short* -- )
|
||||||
LIT '0 .Console/char DEO
|
LIT '0 .Console/write DEO
|
||||||
LIT 'x .Console/char DEO
|
LIT 'x .Console/write DEO
|
||||||
DUP2 #0c SFT2 ,&digit JSR
|
OVR #04 SFT ,&hex JSR
|
||||||
DUP2 #08 SFT2 ,&digit JSR
|
SWP #0f AND ,&hex JSR
|
||||||
DUP2 #04 SFT2 ,&digit JSR
|
DUP #04 SFT ,&hex JSR
|
||||||
,&digit JSR
|
#0f AND ,&hex JMP
|
||||||
|
|
||||||
|
&hex
|
||||||
|
#30 ADD DUP #39 GTH #27 MUL ADD .Console/write DEO
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
&digit
|
@print-byte ( byte -- )
|
||||||
#0f AND DUP #0a LTH ,¬-alpha JCN
|
LIT '0 .Console/write DEO
|
||||||
#27 ADD
|
LIT 'x .Console/write DEO
|
||||||
¬-alpha
|
DUP #04 SFT ,&hex JSR
|
||||||
LIT '0 ADD .Console/char DEO
|
#0f AND ,&hex JMP
|
||||||
POP
|
|
||||||
|
&hex
|
||||||
|
#30 ADD DUP #39 GTH #27 MUL ADD .Console/write DEO
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@print-decimal ( short -- )
|
@print-short-decimal ( short -- )
|
||||||
#00 .number/started STZ
|
#00 .number/started STZ
|
||||||
DUP2 #2710 DIV2 DUP2 ,&digit JSR #2710 MUL2 SUB2
|
DUP2 #2710 DIV2 DUP2 ,&digit JSR #2710 MUL2 SUB2
|
||||||
DUP2 #03e8 DIV2 DUP2 ,&digit JSR #03e8 MUL2 SUB2
|
DUP2 #03e8 DIV2 DUP2 ,&digit JSR #03e8 MUL2 SUB2
|
||||||
|
@ -65,7 +70,7 @@ RTN
|
||||||
DUP2 #000a DIV2 DUP2 ,&digit JSR #000a MUL2 SUB2
|
DUP2 #000a DIV2 DUP2 ,&digit JSR #000a MUL2 SUB2
|
||||||
,&digit JSR
|
,&digit JSR
|
||||||
.number/started LDZ ,&end JCN
|
.number/started LDZ ,&end JCN
|
||||||
LIT '0 .Console/char DEO
|
LIT '0 .Console/write DEO
|
||||||
&end
|
&end
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
@ -73,7 +78,7 @@ RTN
|
||||||
SWP POP
|
SWP POP
|
||||||
DUP .number/started LDZ ORA #02 JCN
|
DUP .number/started LDZ ORA #02 JCN
|
||||||
POP JMP2r
|
POP JMP2r
|
||||||
LIT '0 ADD .Console/char DEO
|
LIT '0 ADD .Console/write DEO
|
||||||
#01 .number/started STZ
|
#01 .number/started STZ
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|
|10 @Console [ &pad $8 &write $1 ]
|
||||||
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
||||||
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@
|
||||||
|
|
||||||
.File/success DEI2 ORA ;on-success JCN2
|
.File/success DEI2 ORA ;on-success JCN2
|
||||||
|
|
||||||
;failedtxt .Console/string DEO2
|
;failedtxt ;print-string JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-success ( -> )
|
@on-success ( -> )
|
||||||
|
|
||||||
;successtxt .Console/string DEO2
|
;successtxt ;print-string JSR2
|
||||||
|
|
||||||
( draw image )
|
( draw image )
|
||||||
MEMORY .Screen/addr DEO2
|
MEMORY .Screen/addr DEO2
|
||||||
|
@ -62,6 +62,15 @@ BRK
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@print-string ( ptr* -- )
|
||||||
|
LDAk DUP ,&keep-going JCN
|
||||||
|
POP POP2 JMP2r
|
||||||
|
|
||||||
|
&keep-going
|
||||||
|
.Console/write DEO
|
||||||
|
#0001 ADD2
|
||||||
|
,print-string JMP
|
||||||
|
|
||||||
@successtxt "Success! 09 $1
|
@successtxt "Success! 09 $1
|
||||||
@failedtxt "Failed. 09 $1
|
@failedtxt "Failed. 09 $1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue