Implement .
This commit is contained in:
41
prelude.f
41
prelude.f
@@ -60,6 +60,47 @@
|
|||||||
: RXTAIL 67 ;
|
: RXTAIL 67 ;
|
||||||
: SYSREADY 68 ;
|
: SYSREADY 68 ;
|
||||||
|
|
||||||
|
\ Printing utilities
|
||||||
|
|
||||||
|
: CR 10 EMIT ;
|
||||||
|
: SPACE 32 EMIT ;
|
||||||
|
|
||||||
|
: CHAR
|
||||||
|
KEY
|
||||||
|
STATE @ 0<> IF
|
||||||
|
LIT LIT , , \ Append LIT <key> to definition if compiling
|
||||||
|
THEN
|
||||||
|
; IMMEDIATE
|
||||||
|
|
||||||
|
: EMIT-DIGIT
|
||||||
|
DUP 10 < IF CHAR 0 ELSE CHAR A THEN
|
||||||
|
+ EMIT
|
||||||
|
;
|
||||||
|
|
||||||
|
: .
|
||||||
|
\ Handle negatives
|
||||||
|
DUP 0< IF CHAR - EMIT NEGATE THEN
|
||||||
|
|
||||||
|
\ Determine starting place value
|
||||||
|
1 BEGIN BASE @ * 2DUP / 0= UNTIL
|
||||||
|
|
||||||
|
\ Print leading non-zero digits
|
||||||
|
BEGIN
|
||||||
|
BASE @ /
|
||||||
|
2DUP / EMIT-DIGIT
|
||||||
|
TUCK MOD SWAP
|
||||||
|
OVER 0=
|
||||||
|
UNTIL
|
||||||
|
|
||||||
|
\ Print any trailing zeros
|
||||||
|
BASE @ /
|
||||||
|
DUP 0<> IF
|
||||||
|
BEGIN CHAR 0 EMIT BASE @ / 0= UNTIL
|
||||||
|
THEN
|
||||||
|
|
||||||
|
2DROP
|
||||||
|
;
|
||||||
|
|
||||||
\ Set SYSREADY high to indicate prelude has finished and enable user
|
\ Set SYSREADY high to indicate prelude has finished and enable user
|
||||||
\ input on the JS side.
|
\ input on the JS side.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user