Make NL, renamed to NL> a bit simpler

It doesn't require emitting words anymore. The rename to NL> is
linked to the upcoming commit.
This commit is contained in:
Virgil Dupras 2021-01-02 10:03:27 -05:00
parent 1fb062e121
commit cbf9ecfb1e
5 changed files with 19 additions and 18 deletions

View File

@ -15,6 +15,6 @@ RS_ADDR 0x80 - CONSTANT SYSVARS
( Update LATEST )
PC ORG @ 8 + !
( TRS-80 wants CR-only newlines )
," ' CR ' NL **! BLK$ FD$ " EOT,
," 13 0x50 RAM+ C! BLK$ FD$ " EOT,
ORG @ |M 2 PC! 2 PC!
H@ |M 2 PC! 2 PC!

19
blk.fs
View File

@ -450,7 +450,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
( We divide by 2 because each PC represents a word. )
: PC H@ ORG @ - 1 RSHIFT ;
( ----- 052 )
: _oor ." arg out of range: " .X SPC ." PC: " PC .X NL ABORT ;
: _oor ." arg out of range: " .X SPC ." PC: " PC .X NL> ABORT ;
: _r8c DUP 7 > IF _oor THEN ;
: _r32c DUP 31 > IF _oor THEN ;
: _r16+c _r32c DUP 16 < IF _oor THEN ;
@ -610,7 +610,7 @@ See doc/ed.txt
1 7 LOADR+
( ----- 106 )
CREATE ACC 0 ,
: _LIST ." Block " DUP . NL LIST ;
: _LIST ." Block " DUP . NL> LIST ;
: L BLK> @ _LIST ;
: B BLK> @ 1- BLK@ L ;
: N BLK> @ 1+ BLK@ L ;
@ -1717,9 +1717,8 @@ with "390 LOAD"
( ----- 356 )
SYSVARS 0x53 + :** EMIT
: STYPE C@+ ( a len ) 0 DO C@+ EMIT LOOP DROP ;
: BS 8 EMIT ; : CR 13 EMIT ;
: CRLF CR 10 EMIT ; : SPC 32 EMIT ;
SYSVARS 0x0a + :** NL
: BS 8 EMIT ; : SPC 32 EMIT ;
: NL> 0x50 RAM+ C@ ?DUP IF EMIT ELSE 13 EMIT 10 EMIT THEN ;
: ERR STYPE ABORT ;
: (uflw) LIT" stack underflow" ERR ;
XCURRENT @ _xapply ORG @ 0x06 ( stable ABI uflw ) + !
@ -1968,7 +1967,7 @@ SYSVARS 0x0c + :** C<*
DROP ( a )
8 0 DO
C@+ DUP 0x20 0x7e =><= NOT IF DROP '.' THEN EMIT
LOOP NL ;
LOOP NL> ;
: DUMP ( n a -- )
SWAP 8 /MOD SWAP IF 1+ THEN
0 DO _ LOOP ;
@ -2038,14 +2037,14 @@ SYSVARS 0x55 + :** KEY?
64 I * BLK( + DUP 64 + SWAP DO
I C@ DUP 0x1f > IF EMIT ELSE DROP LEAVE THEN
LOOP
NL
NL>
LOOP ;
( ----- 383 )
: INTERPRET
BEGIN
WORD DUP @ 0x0401 = ( EOT ) IF DROP EXIT THEN
FIND NOT IF (parse) ELSE EXECUTE THEN
C<? NOT IF SPC LIT" ok" STYPE NL THEN
C<? NOT IF SPC LIT" ok" STYPE NL> THEN
AGAIN ;
( Read from BOOT C< PTR and inc it. )
: (boot<)
@ -2085,13 +2084,13 @@ SYSVARS 0x55 + :** KEY?
0x02 RAM+ CURRENT* !
CURRENT @ 0x2e RAM+ ! ( 2e == BOOT C< PTR )
0 0x08 RAM+ ! ( 08 == C<* override )
0 0x50 RAM+ C! ( NL> )
['] (emit) ['] EMIT **! ['] (key?) ['] KEY? **!
['] CRLF ['] NL **!
['] (boot<) ['] C<* **!
( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ ! INTERPRET
RDLN$ LIT" _sys" [entry]
LIT" Collapse OS" STYPE NL (main) ;
LIT" Collapse OS" STYPE NL> (main) ;
XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
1 4 LOADR+
( ----- 391 )

Binary file not shown.

View File

@ -253,21 +253,20 @@ KEY? -- c? f Polls the keyboard for a key. If a key is
pressed, f is true and c is the char. Other-
wise, f is false and c is *not* on the stack.
KEY -- c Get char c from direct input
NL> -- Emit newline
PC! c a -- Spit c to port a
PC@ a -- c Fetch c from port a
SPC -- Emit space character
WORD -- a Read one word from buffered input and push its
addr. Always null terminated. If ASCII EOT is
encountered, a will point to it (it is cons-
idered a word).
There are also ascii const emitters:
BS CR LF SPC CRLF
KEY? and EMIT are ialiases to (key?) and (emit) (see TTY proto-
col in protocol.txt). KEY is a loop over KEY?.
NL is an ialias that points to CRLF by default and that should
generally be used when we want to emit a newline.
NL> spits CRLF by default, but can be configured to spit an
alternate newline char. See impl.txt.
# Disk

View File

@ -162,8 +162,8 @@ SYSVARS FUTURE USES +3c BLK(*
+02 CURRENT +3e ~C!*
+04 HERE +41 ~C!ERR
+06 C<? +42 FUTURE USES
+08 C<* override +43 FUTURE USES
+0a NL ialias +51 CURRENTPTR
+08 C<* override +50 NL> character
+0a FUTURE USES +51 CURRENTPTR
+0c C<* +53 EMIT ialias
+0e WORDBUF +55 KEY? ialias
+2e BOOT C< PTR +57 FUTURE USES
@ -201,6 +201,9 @@ Register usage is arch-dependent, see boot code for details.
this byte to a nonzero value. Otherwise, stays at zero. Has to
be reset to zero manually after an error.
NL> is a single byte. If zero (default), NL> spits CR/LF. Other-
wise, it spits the value of RAM+50.
DRIVERS section is reserved for recipe-specific drivers.
FUTURE USES section is unused for now.