87 lines
1.6 KiB
Plaintext
87 lines
1.6 KiB
Plaintext
|
( dev/console )
|
||
|
|
||
|
%RTN { JMP2r }
|
||
|
%PRINT { .Console/string DEO2 }
|
||
|
%BR { #0a .Console/char DEO }
|
||
|
|
||
|
( devices )
|
||
|
|
||
|
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|
||
|
|
||
|
( variables )
|
||
|
|
||
|
|0000
|
||
|
|
||
|
@number [ &started $1 ]
|
||
|
|
||
|
( init )
|
||
|
|
||
|
|0100 ( -> )
|
||
|
|
||
|
[ ;char-txt PRINT ] #42 .Console/char DEO BR
|
||
|
[ ;byte-txt PRINT ] #ab .Console/byte DEO BR
|
||
|
[ ;short-txt PRINT ] #cdef .Console/short DEO2 BR
|
||
|
[ ;string-txt PRINT ] ;hello-word .Console/string DEO2 BR
|
||
|
|
||
|
;hello-word ;print JSR2
|
||
|
#ffff ;print-hexadecimal JSR2
|
||
|
;is-word ;print JSR2
|
||
|
#ffff ;print-decimal JSR2
|
||
|
|
||
|
BRK
|
||
|
|
||
|
@print ( addr -- )
|
||
|
|
||
|
&loop
|
||
|
( send ) DUP2 GET .Console/char DEO
|
||
|
( incr ) #0001 ADD2
|
||
|
( loop ) DUP2 GET ,&loop JNZ
|
||
|
POP2
|
||
|
|
||
|
RTN
|
||
|
|
||
|
@print-hexadecimal ( short -- )
|
||
|
LIT '0 .Console/char DEO
|
||
|
LIT 'x .Console/char DEO
|
||
|
DUP2 #000c SFT2 ,&digit JSR
|
||
|
DUP2 #0008 SFT2 ,&digit JSR
|
||
|
DUP2 #0004 SFT2 ,&digit JSR
|
||
|
,&digit JSR
|
||
|
RTN
|
||
|
|
||
|
&digit
|
||
|
#0f AND DUP #0a LTH ,¬-alpha JNZ
|
||
|
#27 ADD
|
||
|
¬-alpha
|
||
|
LIT '0 ADD .Console/char DEO
|
||
|
POP
|
||
|
RTN
|
||
|
|
||
|
@print-decimal ( short -- )
|
||
|
#00 .number/started POK
|
||
|
DUP2 #2710 DIV2 DUP2 ,&digit JSR #2710 MUL2 SUB2
|
||
|
DUP2 #03e8 DIV2 DUP2 ,&digit JSR #03e8 MUL2 SUB2
|
||
|
DUP2 #0064 DIV2 DUP2 ,&digit JSR #0064 MUL2 SUB2
|
||
|
DUP2 #000a DIV2 DUP2 ,&digit JSR #000a MUL2 SUB2
|
||
|
,&digit JSR
|
||
|
.number/started PEK ,&end JNZ
|
||
|
LIT '0 .Console/char DEO
|
||
|
&end
|
||
|
RTN
|
||
|
|
||
|
&digit
|
||
|
SWP POP
|
||
|
DUP .number/started PEK ORA #02 JNZ
|
||
|
POP JMP2r
|
||
|
LIT '0 ADD .Console/char DEO
|
||
|
#01 .number/started POK
|
||
|
RTN
|
||
|
|
||
|
@char-txt "char: 20 $1
|
||
|
@byte-txt "byte: 20 $1
|
||
|
@short-txt "short: 20 $1
|
||
|
@string-txt "string: 20 $1
|
||
|
|
||
|
@hello-word "hello 20 "World! 0a 00
|
||
|
@is-word 20 "is 20 00
|