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

forth: make readline skip prompt when appropriate

This commit is contained in:
Virgil Dupras 2020-03-21 14:59:12 -04:00
parent b47a3ee234
commit 9791c0957d
2 changed files with 32 additions and 6 deletions

View File

@ -53,6 +53,9 @@
.equ HERE @+2 .equ HERE @+2
; Interpreter pointer. See Execution model comment below. ; Interpreter pointer. See Execution model comment below.
.equ IP @+2 .equ IP @+2
; Global flags
; Bit 0: whether the interpreter is executing a word (as opposed to parsing)
.equ FLAGS @+2
; Pointer to the system's number parsing function. It points to then entry that ; Pointer to the system's number parsing function. It points to then entry that
; had the "(parse)" name at startup. During stage0, it's out builtin PARSE, ; had the "(parse)" name at startup. During stage0, it's out builtin PARSE,
; but at stage1, it becomes "(parse)" from core.fs. It can also be changed at ; but at stage1, it becomes "(parse)" from core.fs. It can also be changed at
@ -170,15 +173,29 @@ INTERPRET:
.dw FIND_ .dw FIND_
.dw CSKIP .dw CSKIP
.dw FBR .dw FBR
.db 6 .db 34
; It's a word, execute it ; It's a word, execute it
.dw FLAGS_
.dw FETCH
.dw NUMBER
.dw 0x0001 ; Bit 0 on
.dw OR
.dw FLAGS_
.dw STORE
.dw EXECUTE .dw EXECUTE
.dw FLAGS_
.dw FETCH
.dw NUMBER
.dw 0xfffe ; Bit 0 off
.dw AND
.dw FLAGS_
.dw STORE
.dw BBR .dw BBR
.db 13 .db 41
; FBR mark, try number ; FBR mark, try number
.dw PARSEI .dw PARSEI
.dw BBR .dw BBR
.db 18 .db 46
; infinite loop ; infinite loop
; *** Collapse OS lib copy *** ; *** Collapse OS lib copy ***
@ -1334,10 +1351,18 @@ WORDBUF_:
.dw sysvarWord .dw sysvarWord
.dw WORDBUF .dw WORDBUF
.db "FLAGS"
.fill 2
.dw WORDBUF_
.db 0
FLAGS_:
.dw sysvarWord
.dw FLAGS
; ( n a -- ) ; ( n a -- )
.db "!" .db "!"
.fill 6 .fill 6
.dw WORDBUF_ .dw FLAGS_
.db 0 .db 0
STORE: STORE:
.dw nativeWord .dw nativeWord

View File

@ -61,8 +61,9 @@
( Read one line in input buffer and make IN> point to it ) ( Read one line in input buffer and make IN> point to it )
: (rdln) : (rdln)
( TODO: don't emit prompt in middle of defs and comments ) ( Should we prompt? if we're executing a word, FLAGS bit
LF '>' EMIT SPC 0, then we shouldn't. )
FLAGS @ 0x1 AND NOT IF LF '>' EMIT SPC THEN
(infl) (infl)
BEGIN (rdlnc) NOT UNTIL BEGIN (rdlnc) NOT UNTIL
IN( @ IN> ! IN( @ IN> !