1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 15:18:05 +11:00

Change C<? mechanic

It's now a simple flag updated by the C< implementation. No more
routine pointer.

The goal is to avoid tons of "ok" during a LOAD operation.
This commit is contained in:
Virgil Dupras 2020-04-25 09:10:25 -04:00
parent 4160c8ebbf
commit 389b23fe1a
5 changed files with 22 additions and 15 deletions

View File

@ -1,5 +1,6 @@
C<?* is a pointer to a word being called by C<?. If 0 or 1, C<? is a flag indicating whether a character is waiting in the
will return that value as-is. input stream. 1 means yes, 0 means no. It is the responsibility
of C<* to update that flag.
WORDBUF is the buffer used by WORD WORDBUF is the buffer used by WORD
@ -12,5 +13,4 @@ jump to this address. If you use one of those slots for an
interrupt, write a jump to the appropriate offset in that RAM interrupt, write a jump to the appropriate offset in that RAM
location. location.
(cont.) (cont.)

View File

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

Binary file not shown.

View File

@ -61,17 +61,21 @@
; ;
: LOAD : LOAD
( save BLK>, C<* override and boot< ptr to RSP ) ( save restorable variables to RSP )
BLK> @ >R BLK> @ >R
0x08 RAM+ @ >R 0x08 RAM+ @ >R
0x2e RAM+ @ >R 0x06 RAM+ @ >R ( C<? )
0x2e RAM+ @ >R ( boot ptr )
BLK@ BLK@
( Point to beginning of BLK ) ( Point to beginning of BLK )
BLK( 0x2e RAM+ ! BLK( 0x2e RAM+ !
( 08 == C<* override ) ( 08 == C<* override )
['] _ 0x08 RAM+ ! ['] _ 0x08 RAM+ !
( While we interpret, don't print "ok" after every word )
1 0x06 RAM+ ! ( 06 == C<? )
INTERPRET INTERPRET
R> 0x2e RAM+ ! R> 0x2e RAM+ !
R> 0x06 RAM+ !
( Before we restore C<* are we restoring it to "_"? ( Before we restore C<* are we restoring it to "_"?
if yes, it means we're in a nested LOAD which means we if yes, it means we're in a nested LOAD which means we
should also load back the saved BLK>. Otherwise, we can should also load back the saved BLK>. Otherwise, we can

View File

@ -59,15 +59,18 @@
LF IN( IN> ! LF IN( IN> !
; ;
: RDLN<? IN> @ C@ ; ( And finally, implement C<* )
( And finally, implement a replacement for the (c<) routine )
: RDLN< : RDLN<
RDLN<? ( c ) IN> @ C@
( not EOL? good, inc and return ) DUP IF
DUP IF 1 IN> +! EXIT THEN ( c ) ( not EOL? good, inc and return )
( EOL ? readline. we still return typed char though ) 1 IN> +!
(rdln) ( c ) ELSE
( EOL ? readline. we still return null though )
(rdln)
THEN
( update C<? flag )
IN> @ C@ 0 > 0x06 RAM+ ! ( 06 == C<? )
; ;
( Initializes the readln subsystem ) ( Initializes the readln subsystem )
@ -78,7 +81,7 @@
the last typed 0x0a and one for the following NULL. ) the last typed 0x0a and one for the following NULL. )
INBUFSZ 4 + ALLOT INBUFSZ 4 + ALLOT
(infl) (infl)
['] RDLN<? 0x06 RAM+ !
['] RDLN< 0x0c RAM+ ! ['] RDLN< 0x0c RAM+ !
1 0x06 RAM+ ! ( 06 == C<? )
; ;