From af39b37dd158bc5f92546c212413c2f35d1d7074 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 24 Apr 2020 12:10:07 -0400 Subject: [PATCH] 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. --- blk/061 | 2 +- blk/081 | 6 +++--- blk/082 | 10 +++++----- blk/083 | 12 ++++++------ blk/084 | 14 +++++++------- blk/393 | 6 +----- blk/398 | 3 ++- blk/403 | 9 ++------- blk/405 | 4 +++- emul/forth/run.fs | 1 + emul/forth/z80c.bin | Bin 2187 -> 2212 bytes forth/core.fs | 2 +- forth/print.fs | 1 + forth/readln.fs | 12 ++++++------ 14 files changed, 39 insertions(+), 43 deletions(-) diff --git a/blk/061 b/blk/061 index 3968fee..01b0c4e 100644 --- a/blk/061 +++ b/blk/061 @@ -1,6 +1,6 @@ -(cont.) ." xxx" -- *I* Compiles string literal xxx followed by a call to (print). +C IF EXECUTE THEN ( 06 == CJL~M@O#VjXX z8W6hNWHv>zWa%P@lS>xe0ujN@&B6bm$oamPic2ov^ZtCE=Y5m?kUjc@!B;H#zc8cO zP}q64yH!ksGLGpTig~o*(c_Af0W`*19x7F*Tzgn6JCM?cqAP4zwI9@+dC-l|+JbJw z?IZ}}kG3yuu%>^TxJLM$*%)uck7X+b(l8 z6P95h`{Kn3)+CIxX21xEwzrJ@B>5Td|&U27W|HQ@PQao ztl({SUTznkK*AX7`?3WH7Hv_oR^~vXr4$?yb)F%?rS1q!vt;Gsl~2V{MivcXG@;Z; z^6w!|Fe28a#WR%1h^b9b&uAV_fU@5Wz^?|B+|CYIzK#o)?B1vjVr^{sY@Hfa?zb!V~4YS_Hf9)f)F2 zH4h3RVjX6|taZ2H6%p~XS_y86iRO~9;KnF0{jb{O6wFjlfr1N@?k+~l{_0ArW#FEW znQ#d<#5z)mSQGb|FarZ6WG|0%EzD8Z2|a?TL^P z&V=INOvGaB3E8yT$FHpRJ0UiG7U4w6U)g@PR$c^6KNK&Nb>QG4wYjR163wGBhDygx z>3GKwgG9k+L4D1KCXqCH V2*(i@Mvoa!=3MxJoR_Zx`v;I1poahe diff --git a/forth/core.fs b/forth/core.fs index 0bfab65..981338f 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -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 diff --git a/forth/print.fs b/forth/print.fs index 7f55ca4..c6f74a0 100644 --- a/forth/print.fs +++ b/forth/print.fs @@ -34,3 +34,4 @@ : SPC 32 EMIT ; : (wnf) (print) SPC ABORT" word not found" ; +: (ok) SPC ." ok" CRLF ; diff --git a/forth/readln.fs b/forth/readln.fs index 8566a62..3822b57 100644 --- a/forth/readln.fs +++ b/forth/readln.fs @@ -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 @ C@ ; + ( And finally, implement a replacement for the (c<) routine ) -: (rdln<) - IN> @ C@ ( c ) +: RDLN< + RDLN +! 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