From 58e88119ec465789da43d3ae67ee5f5ac4fc2c80 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 5 Apr 2020 09:09:00 -0400 Subject: [PATCH] rc2014: Forth Collapse OS, fully operational! --- forth/readln.fs | 10 ++++++---- recipes/rc2014/README.md | 13 ++++++------- recipes/rc2014/run.fs | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/forth/readln.fs b/forth/readln.fs index d97b1fa..3561a65 100644 --- a/forth/readln.fs +++ b/forth/readln.fs @@ -40,12 +40,14 @@ ; ( read one char into input buffer and returns whether we - should continue, that is, whether newline was not met. ) + should continue, that is, whether CR was not met. ) : (rdlnc) ( -- f ) ( buffer overflow? same as if we typed a newline ) IN> @ IN) @ = IF 0x0a ELSE KEY THEN ( c ) ( del? same as backspace ) DUP 0x7f = IF DROP 0x8 THEN + ( lf? same as cr ) + DUP 0x0a = IF DROP 0xd THEN ( echo back ) DUP EMIT ( c ) ( bacspace? handle and exit ) @@ -57,17 +59,17 @@ our string ) IN> @ ! 1 IN> +! ( c ) ( if newline, replace with zero to indicate EOL ) - DUP 0xa = IF DROP 0 THEN + DUP 0xd = IF DROP 0 THEN ; ( 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 LF '>' EMIT SPC THEN + FLAGS @ 0x1 AND NOT IF '>' EMIT SPC THEN (infl) BEGIN (rdlnc) NOT UNTIL - IN( @ IN> ! + LF IN( @ IN> ! ; ( And finally, implement a replacement for the (c<) routine ) diff --git a/recipes/rc2014/README.md b/recipes/rc2014/README.md index 6fb15ab..0c5a521 100644 --- a/recipes/rc2014/README.md +++ b/recipes/rc2014/README.md @@ -95,18 +95,17 @@ identify the tty bound to it (in my case, `/dev/ttyUSB0`). Then: Press the reset button on the RC2014 to have Forth begin its bootstrap process. Note that it has to build more than half of itself from source. It takes a -while (TODO: indicate how many minutes). +while about 30 seconds to complete. Once bootstrapping is done, you'll get a and you should see the Collapse OS prompt. That's a full Forth interpreter. You can have fun right now. -However, that multi-minutes boot is kinda annoying. Moreover, that bootstrap -code being in source form takes precious space from our 8K ROM. We already have -our compiled dictionary in memory. All we need to have a instant-booting Forth -is to combine our stage1 with our compiled dict in memory, after some -relinking. +However, that long boot time is kinda annoying. Moreover, that bootstrap code +being in source form takes precious space from our 8K ROM. We already have our +compiled dictionary in memory. All we need to have a instant-booting Forth is +to combine our stage1 with our compiled dict in memory, after some relinking. -TODO: write this. +TODO: write this, do this. [rc2014]: https://rc2014.co.uk [romwrite]: https://github.com/hsoft/romwrite diff --git a/recipes/rc2014/run.fs b/recipes/rc2014/run.fs index 96d239b..e9b38e8 100644 --- a/recipes/rc2014/run.fs +++ b/recipes/rc2014/run.fs @@ -1,7 +1,7 @@ : INIT ACIA$ (c<$) - ." Collapse OS" LF + ." Collapse OS" CR LF ( 0c == CINPTR ) ['] (c<) 0x0c RAM+ ! ;