1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 05:48:06 +11:00
collapseos/forth/print.fs
2020-04-16 18:58:11 -04:00

36 lines
712 B
Forth

( Words allowing printing strings. Require core )
( This used to be in core, but some drivers providing EMIT
are much much easier to write with access to core words,
and these words below need EMIT... )
: (print)
BEGIN
C@+ ( a+1 c )
( exit if null )
DUP NOT IF 2DROP EXIT THEN
EMIT ( a )
AGAIN
;
: ."
34 , ( 34 == litWord )
BEGIN
C<
( 34 is ASCII for " )
DUP 34 = IF DROP 0 THEN
DUP C,
NOT UNTIL
COMPILE (print)
; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
: (uflw) ABORT" stack underflow" ;
: (wnf) ABORT" word not found" ;
: BS 8 EMIT ;
: LF 10 EMIT ;
: CR 13 EMIT ;
: CRLF CR LF ;
: SPC 32 EMIT ;