Pārlūkot izejas kodu

rc2014: Forth Collapse OS, fully operational!

pull/102/head
Virgil Dupras pirms 4 gadiem
vecāks
revīzija
58e88119ec
3 mainītis faili ar 13 papildinājumiem un 12 dzēšanām
  1. +6
    -4
      forth/readln.fs
  2. +6
    -7
      recipes/rc2014/README.md
  3. +1
    -1
      recipes/rc2014/run.fs

+ 6
- 4
forth/readln.fs Parādīt failu

@@ -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 )


+ 6
- 7
recipes/rc2014/README.md Parādīt failu

@@ -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
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 [rc2014]: https://rc2014.co.uk
[romwrite]: https://github.com/hsoft/romwrite [romwrite]: https://github.com/hsoft/romwrite


+ 1
- 1
recipes/rc2014/run.fs Parādīt failu

@@ -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+ !
; ;


Notiek ielāde…
Atcelt
Saglabāt