From aec19e5c8756a0e73203cb9ecb8a3f04e1d7ad2d Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 14 Apr 2020 18:15:07 -0400 Subject: [PATCH] Add word "LOAD" --- blk/001 | 2 +- blk/064 | 1 + blk/100 | 10 ++++++++++ blk/102 | 2 ++ emul/forth/z80c.bin | Bin 2190 -> 2196 bytes forth/blk.fs | 30 ++++++++++++++++++++++++++++-- forth/icore.fs | 4 ++-- 7 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 blk/100 create mode 100644 blk/102 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 3f44d696afa0acd7230c97cf0ff774d0a8a2f1ec..5efc075d11ca13cee1ae76d027cd491d9efc998d 100644 GIT binary patch delta 73 zcmeAZoFcfPpPe%)KflCA)0lyM@>KQ^77%apD|Q{m*vaA?!73&k1q>Vv{R|NdEDR28 b5e!@mJ6OD!`x)dpA{cJ{cV>t;WncsV>)jG) delta 49 zcmbOt*eAH5pPen)M$>?SW%3O65XR)mAJ}ymqbAF81T*SQF60pBk>rSAxb@$eA>NdM F5dc|(4I2Oe 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