31 lines
485 B
Text
31 lines
485 B
Text
(
|
|
Print a hex byte to decimal.
|
|
)
|
|
|
|
( macros )
|
|
%\n { 0a }
|
|
%newline { [ LIT2 \n -Console/write ] DEO }
|
|
|
|
( devices )
|
|
|10 @Console/vector $2 &read $1 ( &pad is unused ) &pad $5 &write $1 &error $1
|
|
|
|
( main program )
|
|
|100
|
|
|
|
@on-reset ( -> )
|
|
#42 print/dec newline
|
|
BRK
|
|
|
|
( library )
|
|
@print/dec ( dec -- )
|
|
DUP #64 DIV /dec/try
|
|
DUP #0a DIV /dec/try
|
|
( >> )
|
|
|
|
&dec/num ( num -- )
|
|
#0a DIVk MUL SUB [ LIT "0 ] ADD .Console/write DEO
|
|
JMP2r
|
|
|
|
&dec/try ( num -- )
|
|
DUP ?/dec/num
|
|
POP JMP2r
|