2020-04-14 09:05:43 -04:00
|
|
|
( I/O blocks )
|
|
|
|
|
|
|
|
: BLKMEM+ 0x57 RAM+ @ + ;
|
|
|
|
( n -- Fetches block n and write it to BLK( )
|
|
|
|
: BLK@* 0 BLKMEM+ ;
|
|
|
|
( n -- Write back BLK( to storage at block n )
|
|
|
|
: BLK!* 2 BLKMEM+ ;
|
|
|
|
( Current blk pointer in ( )
|
|
|
|
: BLK> 4 BLKMEM+ ;
|
2020-04-16 20:59:20 -04:00
|
|
|
( Whether buffer is dirty )
|
|
|
|
: BLKDTY 6 BLKMEM+ ;
|
|
|
|
: BLK( 8 BLKMEM+ ;
|
2020-04-14 09:05:43 -04:00
|
|
|
|
|
|
|
: BLK$
|
|
|
|
H@ 0x57 RAM+ !
|
2020-04-16 20:59:20 -04:00
|
|
|
( 1024 for the block, 8 for variables )
|
|
|
|
1032 ALLOT
|
2020-04-14 18:15:07 -04:00
|
|
|
( LOAD detects end of block with ASCII EOT. This is why
|
|
|
|
we write it there. EOT == 0x04 )
|
|
|
|
4 C,
|
2020-04-16 20:59:20 -04:00
|
|
|
0 BLKDTY !
|
2020-04-14 09:05:43 -04:00
|
|
|
-1 BLK> !
|
|
|
|
;
|
|
|
|
|
2020-04-16 20:59:20 -04:00
|
|
|
( -- )
|
|
|
|
: BLK!
|
|
|
|
BLK> @ BLK!* @ EXECUTE
|
|
|
|
0 BLKDTY !
|
|
|
|
;
|
|
|
|
|
2020-04-16 17:22:18 -04:00
|
|
|
( n -- )
|
2020-04-14 09:05:43 -04:00
|
|
|
: BLK@
|
2020-04-16 15:59:43 -04:00
|
|
|
DUP BLK> @ = IF DROP EXIT THEN
|
2020-04-16 20:59:20 -04:00
|
|
|
BLKDTY @ IF BLK! THEN
|
2020-04-14 09:05:43 -04:00
|
|
|
DUP BLK> ! BLK@* @ EXECUTE
|
|
|
|
;
|
|
|
|
|
2020-04-16 20:59:20 -04:00
|
|
|
: BLK!! 1 BLKDTY ! ;
|
2020-04-16 17:22:18 -04:00
|
|
|
|
2020-04-14 09:05:43 -04:00
|
|
|
: .2 DUP 10 < IF SPC THEN . ;
|
|
|
|
|
|
|
|
: LIST
|
|
|
|
BLK@
|
|
|
|
16 0 DO
|
2020-04-15 21:29:39 -04:00
|
|
|
I 1+ .2 SPC
|
2020-04-14 09:05:43 -04:00
|
|
|
64 I * BLK( + (print)
|
|
|
|
CRLF
|
|
|
|
LOOP
|
|
|
|
;
|
2020-04-14 18:15:07 -04:00
|
|
|
|
|
|
|
: _
|
|
|
|
(boot<)
|
|
|
|
DUP 4 = IF
|
2020-04-16 20:59:20 -04:00
|
|
|
( We drop our char, but also "a" from WORD: it won't
|
|
|
|
have the opportunity to balance PSP because we're
|
|
|
|
EXIT!ing. )
|
|
|
|
2DROP
|
2020-04-14 18:15:07 -04:00
|
|
|
( We're finished interpreting )
|
2020-04-14 21:04:07 -04:00
|
|
|
EXIT!
|
2020-04-14 18:15:07 -04:00
|
|
|
THEN
|
|
|
|
;
|
|
|
|
|
|
|
|
: LOAD
|
2020-04-25 09:10:25 -04:00
|
|
|
( save restorable variables to RSP )
|
2020-04-14 21:04:07 -04:00
|
|
|
BLK> @ >R
|
2020-04-24 14:10:40 -04:00
|
|
|
0x08 RAM+ @ >R
|
2020-04-25 09:10:25 -04:00
|
|
|
0x06 RAM+ @ >R ( C<? )
|
|
|
|
0x2e RAM+ @ >R ( boot ptr )
|
2020-04-14 18:15:07 -04:00
|
|
|
BLK@
|
2020-04-14 21:04:07 -04:00
|
|
|
( Point to beginning of BLK )
|
2020-04-14 18:15:07 -04:00
|
|
|
BLK( 0x2e RAM+ !
|
2020-04-24 14:10:40 -04:00
|
|
|
( 08 == C<* override )
|
|
|
|
['] _ 0x08 RAM+ !
|
2020-04-25 09:10:25 -04:00
|
|
|
( While we interpret, don't print "ok" after every word )
|
|
|
|
1 0x06 RAM+ ! ( 06 == C<? )
|
2020-04-14 21:04:07 -04:00
|
|
|
INTERPRET
|
|
|
|
R> 0x2e RAM+ !
|
2020-04-25 09:10:25 -04:00
|
|
|
R> 0x06 RAM+ !
|
2020-04-24 14:10:40 -04:00
|
|
|
( Before we restore C<* are we restoring it to "_"?
|
2020-04-14 21:04:07 -04:00
|
|
|
if yes, it means we're in a nested LOAD which means we
|
|
|
|
should also load back the saved BLK>. Otherwise, we can
|
|
|
|
ignore the BLK> from RSP. )
|
2020-04-24 14:10:40 -04:00
|
|
|
I 0x08 RAM+ @ = IF
|
2020-04-14 21:04:07 -04:00
|
|
|
( nested load )
|
2020-04-24 14:10:40 -04:00
|
|
|
R> DROP ( C<* )
|
2020-04-14 21:04:07 -04:00
|
|
|
R> BLK@
|
|
|
|
ELSE
|
|
|
|
( not nested )
|
2020-04-24 14:10:40 -04:00
|
|
|
R> 0x08 RAM+ !
|
2020-04-14 21:04:07 -04:00
|
|
|
R> DROP ( BLK> )
|
|
|
|
THEN
|
2020-04-14 18:15:07 -04:00
|
|
|
;
|
2020-04-22 21:19:12 -04:00
|
|
|
|
|
|
|
( b1 b2 -- )
|
|
|
|
: LOADR 1+ SWAP DO I DUP . CRLF LOAD LOOP ;
|