Replace the "> " prompt with the more traditional "ok" one

This is more than cosmetic, it's also highly usable. The presence
or absence of the "ok" message allows us to know whether the command
aborted. Previously, the "> " prompt appeared when the system expected
a prompt in the INTERPRET context, whether the previous command aborted
or not.

Also, this allows us to get rid of that ugly FLAGS global variable.
This commit is contained in:
Virgil Dupras 2020-04-24 12:10:07 -04:00
parent a699c93509
commit af39b37dd1
14 changed files with 39 additions and 43 deletions

View File

@ -1,6 +1,6 @@
(cont.)
." xxx" -- *I* Compiles string literal xxx followed by a
call to (print).
C<? -- f Returns whether there's a char waiting in buf.
C< -- c Read one char from buffered input.
DUMP n a -- Prints n bytes at addr a in a hexdump format.
Prints in chunks of 8 bytes. Doesn't do partial

View File

@ -2,10 +2,10 @@
RAMSTART INITIAL_SP +53 readln's variables
+02 CURRENT +55 adev's variables
+04 HERE +57 blk's variables
+06 FUTURE USES +59 z80a's variables
+08 FLAGS +5b FUTURE USES
+06 C<?* +59 z80a's variables
+08 FUTURE USES +5b FUTURE USES
+0a PARSEPTR +70 DRIVERS
+0c CINPTR +80 RAMEND
+0c C<* +80 RAMEND
+0e WORDBUF
+2e BOOT C< PTR
+4e INTJUMP

10
blk/082
View File

@ -1,4 +1,4 @@
(cont.) INITIAL_SP holds the initial Stack Pointer value so
INITIAL_SP holds the initial Stack Pointer value so
that we know where to reset it on ABORT
CURRENT points to the last dict entry.
@ -7,10 +7,10 @@ HERE points to current write offset.
IP is the Interpreter Pointer
FLAGS holds global flags. Only used for prompt output control
for now.
PARSEPTR holds routine address called on (parse)
CINPTR holds routine address called on C<
C<* holds routine address called on C<
(cont.)

12
blk/083
View File

@ -1,4 +1,7 @@
(cont.) WORDBUF is the buffer used by WORD
C<?* is a pointer to a word being called by C<?. If 0 or 1,
will return that value as-is.
WORDBUF is the buffer used by WORD
BOOT C< PTR is used when Forth boots from in-memory
source. See "Initialization sequence" below.
@ -9,8 +12,5 @@ jump to this address. If you use one of those slots for an
interrupt, write a jump to the appropriate offset in that RAM
location.
CURRENTPTR points to current CURRENT. The Forth CURRENT word
doesn't return RAM+2 directly, but rather the value at this
address. Most of the time, it points to RAM+2, but sometimes,
when maintaining alternative dicts (during cross compilation
for example), it can point elsewhere. (cont.)
(cont.)

14
blk/084
View File

@ -1,4 +1,10 @@
(cont.) FUTURE USES section is unused for now.
CURRENTPTR points to current CURRENT. The Forth CURRENT word
doesn't return RAM+2 directly, but rather the value at this
address. Most of the time, it points to RAM+2, but sometimes,
when maintaining alternative dicts (during cross compilation
for example), it can point elsewhere.
FUTURE USES section is unused for now.
DRIVERS section is reserved for recipe-specific
drivers. Here is a list of known usages:
@ -8,9 +14,3 @@ drivers. Here is a list of known usages:

View File

@ -1,5 +1,4 @@
: RAM+ [ RAMSTART LITN ] + ;
: FLAGS 0x08 RAM+ ;
: (parse*) 0x0a RAM+ ;
: HERE 0x04 RAM+ ;
: CURRENT* 0x51 RAM+ ;
@ -8,8 +7,5 @@
( w -- a f )
: (find) CURRENT @ SWAP _find ;
: QUIT
0 FLAGS ! (resRS)
LIT< INTERPRET (find) DROP EXECUTE
;
: QUIT (resRS) LIT< INTERPRET (find) DROP EXECUTE ;
394 407 LOADR

View File

@ -2,7 +2,8 @@
for an abort message )
: (parse) (parsed) NOT IF ABORT THEN ;
: C< 0x0c RAM+ @ EXECUTE ( 0c == CINPTR ) ;
: C<? 0x06 RAM+ @ DUP 2 > IF EXECUTE THEN ( 06 == C<?* ) ;
: C< 0x0c RAM+ @ EXECUTE ( 0c == C<* ) ;
: , HERE @ ! HERE @ 2+ HERE ! ;

View File

@ -2,13 +2,8 @@
BEGIN
WORD
(find)
IF
1 FLAGS !
EXECUTE
0 FLAGS !
ELSE
(parse*) @ EXECUTE
THEN
NOT IF (parse*) @ THEN EXECUTE
C<? NOT IF LIT< (ok) (find) IF EXECUTE THEN THEN
AGAIN
;

View File

@ -3,8 +3,10 @@
LIT< (parse) (find) DROP (parse*) !
( 2e == SYSTEM SCRATCHPAD )
CURRENT @ 0x2e RAM+ !
( 0c == CINPTR )
( 0c == C<* )
LIT< (boot<) (find) DROP 0x0c RAM+ !
( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ !
LIT< INIT (find)
IF EXECUTE
ELSE DROP INTERPRET THEN

View File

@ -19,5 +19,6 @@
['] EFS! BLK!* !
RDLN$
LIT< _sys [entry]
." Collapse OS" CRLF
INTERPRET
;

Binary file not shown.

View File

@ -3,7 +3,7 @@
CURRENT @ 1-
DUP C@ 128 OR SWAP C!
;
: [ INTERPRET 1 FLAGS ! ; IMMEDIATE
: [ INTERPRET ; IMMEDIATE
: ] R> DROP ;
: LITS 34 , SCPY ;
: LIT< WORD LITS ; IMMEDIATE

View File

@ -34,3 +34,4 @@
: SPC 32 EMIT ;
: (wnf) (print) SPC ABORT" word not found" ;
: (ok) SPC ." ok" CRLF ;

View File

@ -54,17 +54,16 @@
( Read one line in input buffer and make IN> point to it )
: (rdln)
( Should we prompt? if we're executing a word, FLAGS bit
0, then we shouldn't. )
FLAGS @ 0x1 AND NOT IF '>' EMIT SPC THEN
(infl)
BEGIN (rdlnc) NOT UNTIL
LF IN( IN> !
;
: RDLN<? IN> @ C@ ;
( And finally, implement a replacement for the (c<) routine )
: (rdln<)
IN> @ C@ ( c )
: RDLN<
RDLN<? ( c )
( not EOL? good, inc and return )
DUP IF 1 IN> +! EXIT THEN ( c )
( EOL ? readline. we still return typed char though )
@ -79,6 +78,7 @@
the last typed 0x0a and one for the following NULL. )
INBUFSZ 4 + ALLOT
(infl)
['] (rdln<) 0x0c RAM+ !
['] RDLN<? 0x06 RAM+ !
['] RDLN< 0x0c RAM+ !
;