Add word "LOAD"

This commit is contained in:
Virgil Dupras 2020-04-14 18:15:07 -04:00
parent a67101fb8b
commit aec19e5c87
7 changed files with 44 additions and 5 deletions

View File

@ -1,4 +1,4 @@
MASTER INDEX
3 Usage 30 Dictionary
70 Implementation notes
70 Implementation notes 100 Block explorer

View File

@ -3,3 +3,4 @@ Disk
BLK> -- a Address of the current block variable.
LIST n -- Prints the contents of the block n on screen in the
form of 16 lines of 64 columns.
LOAD n -- Interprets Forth code from block n

10
blk/100 Normal file
View File

@ -0,0 +1,10 @@
Block explorer
This is an application to conveniently browse the contents of
the disk blocks. You can launch it with "102 LOAD".
USAGE: When loaded, the Forth interpreter is replaced by the
explorer interpreter. Typing "Q" quits the program.
Typing a decimal number followed by space or return lists the
contents of that block.

2
blk/102 Normal file
View File

@ -0,0 +1,2 @@
: foo ." Hello world! " 42 . ;
foo

Binary file not shown.

View File

@ -7,11 +7,17 @@
: BLK!* 2 BLKMEM+ ;
( Current blk pointer in ( )
: BLK> 4 BLKMEM+ ;
: BLK( 6 BLKMEM+ ;
( backup for CINPTR when LOADing )
: BLKC<* 6 BLKMEM+ ;
: BLK( 8 BLKMEM+ ;
: BLK$
H@ 0x57 RAM+ !
1030 ALLOT
( 1024 for the block, 8 for variables )
1032 ALLOT
( LOAD detects end of block with ASCII EOT. This is why
we write it there. EOT == 0x04 )
4 C,
-1 BLK> !
;
@ -30,3 +36,23 @@
CRLF
LOOP
;
: _
(boot<)
DUP 4 = IF
DROP
( We're finished interpreting )
BLKC<* @ 0x0c RAM+ !
C<
THEN
;
: LOAD
BLK@
( 2e == BOOT C< PTR )
BLK( 0x2e RAM+ !
( Save current C< ptr )
0x0c RAM+ @ BLKC<* !
( 0c == CINPTR )
['] _ 0x0c RAM+ !
;

View File

@ -178,7 +178,7 @@
( system c< simply reads source from binary, starting at
LATEST. Convenient way to bootstrap a new system. )
: (c<)
: (boot<)
( 2e == BOOT C< PTR )
0x2e RAM+ @ ( a )
DUP C@ ( a c )
@ -192,7 +192,7 @@
( 2e == SYSTEM SCRATCHPAD )
CURRENT @ 0x2e RAM+ !
( 0c == CINPTR )
LIT< (c<) (find) DROP 0x0c RAM+ !
LIT< (boot<) (find) DROP 0x0c RAM+ !
LIT< INIT (find)
IF EXECUTE
ELSE DROP INTERPRET THEN