uxn/projects/examples/devices/console.tal

38 lines
601 B
Tal

( dev/console )
%HALT { #010f DEO }
%EMIT { #18 DEO }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
( init )
|0100 ( -> )
;hello-word
&while
( send ) LDAk EMIT
#20 EMIT
DUP2 ;print-hex JSR2
#20 EMIT
LDAk ;print-hex/byte JSR2
#0a EMIT
INC2 LDAk ,&while JCN
POP2
( stop ) HALT
BRK
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@hello-word "Hello 20 "Uxn!