commit d6d0a04dad4b8891b84ac4dd60259746aef03fba
parent ebf779f0b38bd6bdd896e911424356e2edd4f308
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 4 Jun 2022 13:09:42 -0400
Decouple f<< from rdln
Diffstat:
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/aliases.txt b/aliases.txt
@@ -30,6 +30,7 @@ in> inptr
<< shl
>> shr
boot< bootrd
+iin< iinrd
in< inrd
[c]? findchar
[]= rangeeq
@@ -38,4 +39,3 @@ in< inrd
' apos
; compstop
: docolon
-f< fread
diff --git a/boot.fs b/boot.fs
@@ -60,7 +60,10 @@ create _ $100 allot
tocstr 5 ( open ) swap 0 0 ( open cstr noflag O_RDONLY ) lnxcall
dup 0< if S" Can't open" stype abort then to curfd ;
create _ 1 allot
-: f< ( -- c-or-0 ) 3 ( read ) curfd _ 1 lnxcall 1 = if _ c@ else 0 then ;
+: fread ( fd -- c-or-0 ) 3 ( read ) swap _ 1 lnxcall 1 = if _ c@ else 0 then ;
+: f< ( -- c-or-0 ) curfd fread ;
+: fin< f< ?dup not if ['] iin< to in< SPC then ;
+: f<< word fopen ['] fin< to in< ;
64 value LNSZ
create in( LNSZ allot
@@ -81,8 +84,6 @@ create in( LNSZ allot
in> in) < if in> c@+ swap to in> else 0 then ;
: rdln< ( -- c ) rdln<? ?dup not if
rdln in( to in> SPC then ;
-: rdln$ ['] rdln< to in< in) to in> ;
-: fin< f< ?dup not if ['] rdln< to in< SPC then ;
-: f<< word fopen ['] fin< to in< ;
+: rdln$ ['] rdln< dup to iin< to in< in) to in> ;
: init S" Dusk OS" stype rdln$ ;
init
diff --git a/dusk.asm b/dusk.asm
@@ -106,6 +106,7 @@ here: resd 1
compiling: resd 1
curword: resb 0x20 ; 1b len, then contents
inptr: resd 1 ; in>
+iinrd: resd 1 ; iin<
inrd: resd 1 ; in<
wnf: resd 1 ; (wnf)
psufl: resd 1 ; (psufl)
@@ -127,7 +128,8 @@ _start:
mov dword [here], herestart
mov dword [current], word_lastxcomp
mov dword [inptr], bootsrc
- mov dword [inrd], word_bootrd
+ mov dword [iinrd], word_bootrd
+ mov dword [inrd], word_iinrd
mov dword [wnf], word_bye
mov dword [psufl], word_bye
mov eax, SYSCALL_CHDIR
@@ -146,6 +148,7 @@ defword 'noop', 4, word_noop, word_bye
defword 'quit', 4, word_quit, word_noop
cld
mov byte [toflag], 0
+ mov dword [inrd], word_iinrd ; make sure input is interactive after a quit
mov esp, rs_top
jmp word_mainloop
diff --git a/xcomp.txt b/xcomp.txt
@@ -32,7 +32,8 @@ alias (psufl)
: move, ( a u -- ) here over allot swap move ;
: ws? SPC <= ;
: boot< in> c@+ swap to in> ;
-alias in<
+alias iin< \ interactive in<
+alias in< \ where "word" feeds itself
: curword ( -- sa sl ) 'curword 1+ 'curword c@ ;
: word ( -- sa sl )
A>r 0 begin drop in< dup ws? not until ( c )