1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-30 21:28:05 +11:00

rc2014: Forth Collapse OS, fully operational!

This commit is contained in:
Virgil Dupras 2020-04-05 09:09:00 -04:00
parent e5f22c7d91
commit 58e88119ec
3 changed files with 13 additions and 12 deletions

View File

@ -40,12 +40,14 @@
; ;
( read one char into input buffer and returns whether we ( 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 ) : (rdlnc) ( -- f )
( buffer overflow? same as if we typed a newline ) ( buffer overflow? same as if we typed a newline )
IN> @ IN) @ = IF 0x0a ELSE KEY THEN ( c ) IN> @ IN) @ = IF 0x0a ELSE KEY THEN ( c )
( del? same as backspace ) ( del? same as backspace )
DUP 0x7f = IF DROP 0x8 THEN DUP 0x7f = IF DROP 0x8 THEN
( lf? same as cr )
DUP 0x0a = IF DROP 0xd THEN
( echo back ) ( echo back )
DUP EMIT ( c ) DUP EMIT ( c )
( bacspace? handle and exit ) ( bacspace? handle and exit )
@ -57,17 +59,17 @@
our string ) our string )
IN> @ ! 1 IN> +! ( c ) IN> @ ! 1 IN> +! ( c )
( if newline, replace with zero to indicate EOL ) ( 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 ) ( Read one line in input buffer and make IN> point to it )
: (rdln) : (rdln)
( Should we prompt? if we're executing a word, FLAGS bit ( Should we prompt? if we're executing a word, FLAGS bit
0, then we shouldn't. ) 0, then we shouldn't. )
FLAGS @ 0x1 AND NOT IF LF '>' EMIT SPC THEN FLAGS @ 0x1 AND NOT IF '>' EMIT SPC THEN
(infl) (infl)
BEGIN (rdlnc) NOT UNTIL BEGIN (rdlnc) NOT UNTIL
IN( @ IN> ! LF IN( @ IN> !
; ;
( And finally, implement a replacement for the (c<) routine ) ( And finally, implement a replacement for the (c<) routine )

View File

@ -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. 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 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 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. prompt. That's a full Forth interpreter. You can have fun right now.
However, that multi-minutes boot is kinda annoying. Moreover, that bootstrap However, that long boot time is kinda annoying. Moreover, that bootstrap code
code being in source form takes precious space from our 8K ROM. We already have being in source form takes precious space from our 8K ROM. We already have our
our compiled dictionary in memory. All we need to have a instant-booting Forth compiled dictionary in memory. All we need to have a instant-booting Forth is
is to combine our stage1 with our compiled dict in memory, after some to combine our stage1 with our compiled dict in memory, after some relinking.
relinking.
TODO: write this. TODO: write this, do this.
[rc2014]: https://rc2014.co.uk [rc2014]: https://rc2014.co.uk
[romwrite]: https://github.com/hsoft/romwrite [romwrite]: https://github.com/hsoft/romwrite

View File

@ -1,7 +1,7 @@
: INIT : INIT
ACIA$ ACIA$
(c<$) (c<$)
." Collapse OS" LF ." Collapse OS" CR LF
( 0c == CINPTR ) ( 0c == CINPTR )
['] (c<) 0x0c RAM+ ! ['] (c<) 0x0c RAM+ !
; ;