From f38de1c151b7453e53085b8bc260c6b0dc00564f Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 29 Apr 2020 21:52:18 -0400 Subject: [PATCH] Introduce the notion of Extra words --- blk/001 | 1 + blk/030 | 3 ++- blk/037 | 4 ++-- blk/102 | 2 +- blk/150 | 14 ++++++++++++++ blk/152 | 3 +++ blk/{427 => 153} | 1 + blk/{428 => 154} | 0 blk/155 | 6 ++++++ blk/156 | 4 ++++ blk/157 | 5 +++++ blk/422 | 4 ++-- blk/434 | 5 ----- blk/435 | 3 --- blk/470 | 5 ----- emul/forth.bin | Bin 5962 -> 5760 bytes 16 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 blk/150 create mode 100644 blk/152 rename blk/{427 => 153} (99%) rename blk/{428 => 154} (100%) create mode 100644 blk/155 create mode 100644 blk/156 create mode 100644 blk/157 diff --git a/blk/001 b/blk/001 index f2c3353..7eb9453 100644 --- a/blk/001 +++ b/blk/001 @@ -3,6 +3,7 @@ MASTER INDEX 3 Usage 30 Dictionary 70 Implementation notes 100 Block editor 120 Linker 140 Addressed devices +150 Extra words 200 Z80 assembler 260 Cross compilation 280 Z80 boot code 350 ACIA driver 370 SD Card driver 390 Inner core diff --git a/blk/030 b/blk/030 index 182071e..919a99d 100644 --- a/blk/030 +++ b/blk/030 @@ -1,6 +1,7 @@ Dictionary -Be sure to read usage guide (B3) first. +List of words defined in Inner core (B390), Core words (B420) +and Extra words (B150). 31 Glossary 34 Symbols 37 Entry management 40 Defining words diff --git a/blk/037 b/blk/037 index 7b689ac..dc63872 100644 --- a/blk/037 +++ b/blk/037 @@ -1,7 +1,7 @@ Entry management -(find) a -- a f Read at a and find it in dict. If found, - f=1 and a = wordref. If not found, f=0 and +'? x -- a f Find x it in dict. If found, f=1 and + a = wordref. If not found, f=0 and a = string addr. ' x -- a Push addr of word x to a. If not found, aborts. diff --git a/blk/102 b/blk/102 index 7d40afa..e3a81dc 100644 --- a/blk/102 +++ b/blk/102 @@ -1,3 +1,4 @@ +152 LOAD ( extras ) 103 105 LOADR : BROWSE @@ -13,4 +14,3 @@ ; - diff --git a/blk/150 b/blk/150 new file mode 100644 index 0000000..ca16a1f --- /dev/null +++ b/blk/150 @@ -0,0 +1,14 @@ +Extra words + +The Core words (B420) section contains the absolute minimum +needed to get a usable Forth interpreter with input buffer and +disk blocks access running. The goal here is to minimize the +binary size of a minimum Collapse OS install. + +Extra words are words you will most likely want because they +are generally useful. They are so useful that they are part +of the Dictionary (B30). + +Some programs need them, so they will automatically LOAD them. +To that end, the loader is conditional: it aborts if extra +words are already present. Load with "152 LOAD". diff --git a/blk/152 b/blk/152 new file mode 100644 index 0000000..e6f2bdf --- /dev/null +++ b/blk/152 @@ -0,0 +1,3 @@ +'? CASE NOT [IF] + 153 157 LOADR +[THEN] DROP ( from '? ) diff --git a/blk/427 b/blk/153 similarity index 99% rename from blk/427 rename to blk/153 index 5e66828..30ead81 100644 --- a/blk/427 +++ b/blk/153 @@ -8,3 +8,4 @@ ; IMMEDIATE : ENDOF [COMPILE] ELSE ; IMMEDIATE + diff --git a/blk/428 b/blk/154 similarity index 100% rename from blk/428 rename to blk/154 diff --git a/blk/155 b/blk/155 new file mode 100644 index 0000000..9d380a4 --- /dev/null +++ b/blk/155 @@ -0,0 +1,6 @@ +: FILL ( a n b -- ) + SWAP 2 PICK + ( a b a+n ) ROT ( b a+n a ) DO ( b ) + DUP I C! + LOOP +; + diff --git a/blk/156 b/blk/156 new file mode 100644 index 0000000..fa80f05 --- /dev/null +++ b/blk/156 @@ -0,0 +1,4 @@ +: EMPTY + LIT< _sys (find) NOT IF ABORT THEN + DUP HERE ! CURRENT ! ; + diff --git a/blk/157 b/blk/157 new file mode 100644 index 0000000..b581795 --- /dev/null +++ b/blk/157 @@ -0,0 +1,5 @@ +: WIPE BLK( 1024 0 FILL BLK!! ; + +( src dst -- ) +: COPY SWAP BLK@ BLK> ! BLK! ; + diff --git a/blk/422 b/blk/422 index 9871af4..48d519b 100644 --- a/blk/422 +++ b/blk/422 @@ -8,9 +8,9 @@ : LITS 34 , SCPY ; : LIT< WORD LITS ; IMMEDIATE : LITA 36 , , ; +: '? WORD (find) ; : ' - WORD (find) (?br) [ 4 , ] EXIT + '? (?br) [ 4 , ] EXIT LIT< (wnf) (find) DROP EXECUTE ; : ['] ' LITA ; IMMEDIATE - diff --git a/blk/434 b/blk/434 index febfb34..fb01d02 100644 --- a/blk/434 +++ b/blk/434 @@ -6,10 +6,5 @@ LOOP 2DROP ; -: FILL ( a n b -- ) - SWAP 2 PICK + ( a b a+n ) ROT ( b a+n a ) DO ( b ) - DUP I C! - LOOP -; : DELW 1- 0 SWAP C! ; : PREV 3 - DUP @ - ; diff --git a/blk/435 b/blk/435 index 8a5bc52..3cb48b4 100644 --- a/blk/435 +++ b/blk/435 @@ -11,6 +11,3 @@ WORD( HERE ! ( w ) PREV CURRENT ! ; -: EMPTY - LIT< _sys (find) NOT IF ABORT THEN - DUP HERE ! CURRENT ! ; diff --git a/blk/470 b/blk/470 index 63dcc04..29bb9b5 100644 --- a/blk/470 +++ b/blk/470 @@ -1,7 +1,2 @@ ( b1 b2 -- ) : LOADR 1+ SWAP DO I DUP . CRLF LOAD LOOP ; - -: WIPE BLK( 1024 0 FILL BLK!! ; - -( src dst -- ) -: COPY SWAP BLK@ BLK> ! BLK! ; diff --git a/emul/forth.bin b/emul/forth.bin index 2b950d399bc892d9010d87770cb8243f710adeaa..3316bad2839be6affc2e523462dd0b7a1a77bea1 100644 GIT binary patch delta 1502 zcmZWpU1%It6h8B_o88%+JF|cJaVt!=+ho_D1X9wfG=Gz9Y~pqkGuzlzlA3OQh#fW| zsg#t^#43i(LkztS!9{#9&^!bog|rc0v`MV!lciD$EvP6pLJ-jxQDHrIW>W+oX6Byn zob%m#zH{z;T{r)%wDUgfd

b<<}*{{c4L0Jo&>JcIZ&+0*(y1$3O%fA`rWn8;wKQ zvCduMba<_H;1Ik`O!v!f9ol!r_1QskH3QNuJ{GuZ1(ADXN zDThakddr!(px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