2020-04-14 23:05:43 +10: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-15 11:04:07 +10:00
|
|
|
: BLK( 6 BLKMEM+ ;
|
2020-04-14 23:05:43 +10:00
|
|
|
|
|
|
|
: BLK$
|
|
|
|
H@ 0x57 RAM+ !
|
2020-04-15 11:04:07 +10:00
|
|
|
( 1024 for the block, 6 for variables )
|
|
|
|
1030 ALLOT
|
2020-04-15 08:15:07 +10:00
|
|
|
( LOAD detects end of block with ASCII EOT. This is why
|
|
|
|
we write it there. EOT == 0x04 )
|
|
|
|
4 C,
|
2020-04-14 23:05:43 +10:00
|
|
|
-1 BLK> !
|
|
|
|
;
|
|
|
|
|
2020-04-17 07:22:18 +10:00
|
|
|
( n -- )
|
2020-04-14 23:05:43 +10:00
|
|
|
: BLK@
|
2020-04-17 05:59:43 +10:00
|
|
|
DUP BLK> @ = IF DROP EXIT THEN
|
2020-04-14 23:05:43 +10:00
|
|
|
DUP BLK> ! BLK@* @ EXECUTE
|
|
|
|
;
|
|
|
|
|
2020-04-17 07:22:18 +10:00
|
|
|
( -- )
|
|
|
|
: BLK! BLK> @ BLK!* @ EXECUTE ;
|
|
|
|
|
2020-04-14 23:05:43 +10:00
|
|
|
: .2 DUP 10 < IF SPC THEN . ;
|
|
|
|
|
|
|
|
: LIST
|
|
|
|
BLK@
|
|
|
|
16 0 DO
|
2020-04-16 11:29:39 +10:00
|
|
|
I 1+ .2 SPC
|
2020-04-14 23:05:43 +10:00
|
|
|
64 I * BLK( + (print)
|
|
|
|
CRLF
|
|
|
|
LOOP
|
|
|
|
;
|
2020-04-15 08:15:07 +10:00
|
|
|
|
|
|
|
: _
|
|
|
|
(boot<)
|
|
|
|
DUP 4 = IF
|
|
|
|
DROP
|
|
|
|
( We're finished interpreting )
|
2020-04-15 11:04:07 +10:00
|
|
|
EXIT!
|
2020-04-15 08:15:07 +10:00
|
|
|
THEN
|
|
|
|
;
|
|
|
|
|
|
|
|
: LOAD
|
2020-04-15 11:04:07 +10:00
|
|
|
( save BLK>, CINPTR and boot< ptr to RSP )
|
|
|
|
BLK> @ >R
|
|
|
|
0x0c RAM+ @ >R
|
|
|
|
0x2e RAM+ @ >R
|
2020-04-15 08:15:07 +10:00
|
|
|
BLK@
|
2020-04-15 11:04:07 +10:00
|
|
|
( Point to beginning of BLK )
|
2020-04-15 08:15:07 +10:00
|
|
|
BLK( 0x2e RAM+ !
|
|
|
|
( 0c == CINPTR )
|
|
|
|
['] _ 0x0c RAM+ !
|
2020-04-15 11:04:07 +10:00
|
|
|
INTERPRET
|
|
|
|
R> 0x2e RAM+ !
|
|
|
|
( Before we restore CINPTR, are we restoring it to "_"?
|
|
|
|
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. )
|
|
|
|
I 0x0c RAM+ @ = IF
|
|
|
|
( nested load )
|
|
|
|
R> DROP ( CINPTR )
|
|
|
|
R> BLK@
|
|
|
|
ELSE
|
|
|
|
( not nested )
|
|
|
|
R> 0x0c RAM+ !
|
|
|
|
R> DROP ( BLK> )
|
|
|
|
THEN
|
2020-04-15 08:15:07 +10:00
|
|
|
;
|