Rename (print) to STYPE

This brings us a bit closer to TYPE from Forth 2012. I don't think
I'll add TYPE (sig "addr len") anytime soon because there is few
use cases for it, but having "STYPE" instead of "(print)" feels
cleaner.
This commit is contained in:
Virgil Dupras 2020-11-28 11:28:28 -05:00
parent b48455e4db
commit db1d6424b3
3 changed files with 12 additions and 9 deletions

14
blk.fs
View File

@ -1753,16 +1753,16 @@ SYSVARS 0x40 + :** A!
SYSVARS 0x42 + :** A, SYSVARS 0x42 + :** A,
( ----- 356 ) ( ----- 356 )
SYSVARS 0x53 + :** EMIT SYSVARS 0x53 + :** EMIT
: (print) C@+ ( a len ) 0 DO C@+ EMIT LOOP DROP ; : STYPE C@+ ( a len ) 0 DO C@+ EMIT LOOP DROP ;
: BS 8 EMIT ; : LF 10 EMIT ; : CR 13 EMIT ; : BS 8 EMIT ; : LF 10 EMIT ; : CR 13 EMIT ;
: CRLF CR LF ; : SPC 32 EMIT ; : CRLF CR LF ; : SPC 32 EMIT ;
SYSVARS 0x0a + :** NL SYSVARS 0x0a + :** NL
: ERR (print) ABORT ; : ERR STYPE ABORT ;
: (uflw) LIT" stack underflow" ERR ; : (uflw) LIT" stack underflow" ERR ;
XCURRENT @ _xapply ORG @ 0x06 ( stable ABI uflw ) + ! XCURRENT @ _xapply ORG @ 0x06 ( stable ABI uflw ) + !
: (oflw) LIT" stack overflow" ERR ; : (oflw) LIT" stack overflow" ERR ;
XCURRENT @ _xapply ORG @ 0x13 ( stable ABI oflw ) + ! XCURRENT @ _xapply ORG @ 0x13 ( stable ABI oflw ) + !
: (wnf) (print) LIT" word not found" ERR ; : (wnf) STYPE LIT" word not found" ERR ;
( ----- 357 ) ( ----- 357 )
( r c -- r f ) ( r c -- r f )
( Parse digit c and accumulate into result r. ( Parse digit c and accumulate into result r.
@ -2102,7 +2102,7 @@ SYSVARS 0x55 + :** KEY
BEGIN BEGIN
WORD DUP @ 0x0401 = ( EOT ) IF DROP EXIT THEN WORD DUP @ 0x0401 = ( EOT ) IF DROP EXIT THEN
FIND NOT IF (parse) ELSE EXECUTE THEN FIND NOT IF (parse) ELSE EXECUTE THEN
C<? NOT IF SPC LIT" ok" (print) NL THEN C<? NOT IF SPC LIT" ok" STYPE NL THEN
AGAIN ; AGAIN ;
( Read from BOOT C< PTR and inc it. ) ( Read from BOOT C< PTR and inc it. )
: (boot<) : (boot<)
@ -2149,7 +2149,7 @@ SYSVARS 0x55 + :** KEY
( boot< always has a char waiting. 06 == C<?* ) ( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ ! INTERPRET 1 0x06 RAM+ ! INTERPRET
RDLN$ LIT" _sys" [entry] RDLN$ LIT" _sys" [entry]
LIT" Collapse OS" (print) NL (main) ; LIT" Collapse OS" STYPE NL (main) ;
XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + ! XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
1 4 LOADR+ 1 4 LOADR+
( ----- 391 ) ( ----- 391 )
@ -2157,7 +2157,7 @@ XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
: :* ( addr -- ) (entry) 4 ( alias ) C, , ; : :* ( addr -- ) (entry) 4 ( alias ) C, , ;
: :** ( addr -- ) (entry) 5 ( ialias ) C, , ; : :** ( addr -- ) (entry) 5 ( ialias ) C, , ;
( ----- 392 ) ( ----- 392 )
: _bchk DUP 0x7f + 0xff > IF LIT" br ovfl" (print) ABORT THEN ; : _bchk DUP 0x7f + 0xff > IF LIT" br ovfl" STYPE ABORT THEN ;
: DO COMPILE 2>R H@ ; IMMEDIATE : DO COMPILE 2>R H@ ; IMMEDIATE
: LOOP COMPILE (loop) H@ - _bchk C, ; IMMEDIATE : LOOP COMPILE (loop) H@ - _bchk C, ; IMMEDIATE
( LEAVE is implemented in low xcomp ) ( LEAVE is implemented in low xcomp )
@ -2190,7 +2190,7 @@ XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
; IMMEDIATE ; IMMEDIATE
( ----- 394 ) ( ----- 394 )
( We don't use ." and ABORT in core, they're not xcomp-ed ) ( We don't use ." and ABORT in core, they're not xcomp-ed )
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE : ." [COMPILE] LIT" COMPILE STYPE ; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE : ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
: BEGIN H@ ; IMMEDIATE : BEGIN H@ ; IMMEDIATE
: AGAIN COMPILE (br) H@ - _bchk C, ; IMMEDIATE : AGAIN COMPILE (br) H@ - _bchk C, ; IMMEDIATE

Binary file not shown.

View File

@ -217,6 +217,9 @@ NOT f -- f Push the logical opposite of f
# Strings # Strings
Strings in Collapse OS begin with a one byte length, followed
by the contents of the string.
LIT" x" -- Read following characters and write to HERE LIT" x" -- Read following characters and write to HERE
as a string literal. as a string literal.
S= a1 a2 -- f Returns whether string a1 == a2. S= a1 a2 -- f Returns whether string a1 == a2.
@ -227,7 +230,7 @@ S= a1 a2 -- f Returns whether string a1 == a2.
result in n as well as whether parsing was a result in n as well as whether parsing was a
success in f (false = failure, true = success in f (false = failure, true =
success) success)
(print) a -- Print string at addr a. Stops at 0x0 or 0xd. STYPE a -- EMIT all chars of string at at addr a.
. n -- Print n in its decimal form . n -- Print n in its decimal form
.x n -- Print n's LSB in hex form. Always 2 .x n -- Print n's LSB in hex form. Always 2
characters. characters.
@ -236,7 +239,7 @@ S= a1 a2 -- f Returns whether string a1 == a2.
"-1 .X" --> ffff "-1 .X" --> ffff
," xxx" -- Write xxx to HERE ," xxx" -- Write xxx to HERE
." xxx" -- *I* Compiles string literal xxx followed by a ." xxx" -- *I* Compiles string literal xxx followed by a
call to (print). call to STYPE.
C<? -- f Returns whether there's a char waiting in buf. C<? -- f Returns whether there's a char waiting in buf.
C< -- c Read one char from buffered input. C< -- c Read one char from buffered input.
EMIT c -- Spit char c to output stream EMIT c -- Spit char c to output stream