diff --git a/blk/001 b/blk/001 index d1c46bb..0151c8e 100644 --- a/blk/001 +++ b/blk/001 @@ -1,4 +1,4 @@ MASTER INDEX 3 Usage 30 Dictionary - 70 Implementation notes + 70 Implementation notes 100 Block explorer diff --git a/blk/064 b/blk/064 index 8b2e2f7..b67c882 100644 --- a/blk/064 +++ b/blk/064 @@ -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 diff --git a/blk/100 b/blk/100 new file mode 100644 index 0000000..8680085 --- /dev/null +++ b/blk/100 @@ -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. diff --git a/blk/102 b/blk/102 new file mode 100644 index 0000000..6e9ec68 --- /dev/null +++ b/blk/102 @@ -0,0 +1,2 @@ +: foo ." Hello world! " 42 . ; +foo diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 3f44d69..5efc075 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/blk.fs b/forth/blk.fs index c64ed6c..04750e3 100644 --- a/forth/blk.fs +++ b/forth/blk.fs @@ -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+ ! +; diff --git a/forth/icore.fs b/forth/icore.fs index 58872e2..2cd62f7 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -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