From 7c20501f2705680018f09468e5d4e9ca73fd45b2 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 13 May 2020 10:14:23 -0400 Subject: [PATCH] Move core's blk to xcomp core (low and high) TODO: implement X['] so that I can remove those XCURRENT patterns. --- blk/131 | 6 +++--- blk/370 | 2 +- blk/393 | 2 +- blk/409 | 13 ++++++++++--- blk/{453 => 416} | 0 blk/{454 => 417} | 0 blk/{455 => 418} | 0 blk/420 | 2 +- blk/431 | 25 ++++++++++++------------- blk/432 | 32 ++++++++++++++++---------------- blk/{458 => 433} | 4 ++-- blk/{459 => 434} | 0 blk/435 | 14 ++++++++++++++ blk/436 | 16 ++++++++++++++++ blk/446 | 9 --------- blk/456 | 13 ------------- blk/457 | 16 ---------------- emul/forth.bin | Bin 5894 -> 5894 bytes emul/xcomp.fs | 2 +- recipes/rc2014/sdcard/README.md | 29 +++++++++++++++++++++++------ recipes/rc2014/xcomp.fs | 3 +-- recipes/ti84/xcomp.fs | 2 +- recipes/trs80/xcomp.fs | 2 +- 23 files changed, 103 insertions(+), 89 deletions(-) rename blk/{453 => 416} (100%) rename blk/{454 => 417} (100%) rename blk/{455 => 418} (100%) rename blk/{458 => 433} (82%) rename blk/{459 => 434} (100%) create mode 100644 blk/435 create mode 100644 blk/436 delete mode 100644 blk/456 delete mode 100644 blk/457 diff --git a/blk/131 b/blk/131 index 2e4efdd..f2a63aa 100644 --- a/blk/131 +++ b/blk/131 @@ -1,9 +1,9 @@ ( Relink a regular Forth full interpreter. ) : RLCORE - LIT< H@ (find) DROP ( target ) + LIT< [ (find) DROP ( target ) DUP 3 - @ ( t prevoff ) - ( subtract H@ name length ) - 2- ( t o ) + ( subtract [ name length ) + 1- ( t o ) RLDICT ; diff --git a/blk/370 b/blk/370 index 0a31674..c430f31 100644 --- a/blk/370 +++ b/blk/370 @@ -1,3 +1,3 @@ SD Card driver -Load range: 372-381 +Load range: 372-387 diff --git a/blk/393 b/blk/393 index 1168ed6..cacd355 100644 --- a/blk/393 +++ b/blk/393 @@ -12,4 +12,4 @@ 0 0x08 RAM+ ! ( 08 == C<* override ) LIT< INTERPRET (find) DROP EXECUTE ; -1 22 LOADR+ +1 25 LOADR+ ( xcomp core low ) diff --git a/blk/409 b/blk/409 index f93ab0e..c7e90d4 100644 --- a/blk/409 +++ b/blk/409 @@ -4,6 +4,13 @@ (find) NOT IF (parse) ELSE EXECUTE THEN C DROP I 2- @ ( I I a ) + = UNTIL + DROP ; diff --git a/blk/453 b/blk/416 similarity index 100% rename from blk/453 rename to blk/416 diff --git a/blk/454 b/blk/417 similarity index 100% rename from blk/454 rename to blk/417 diff --git a/blk/455 b/blk/418 similarity index 100% rename from blk/455 rename to blk/418 diff --git a/blk/420 b/blk/420 index 98a8627..53bf09e 100644 --- a/blk/420 +++ b/blk/420 @@ -1 +1 @@ -1 12 LOADR+ ( xcomp core high ) +1 16 LOADR+ ( xcomp core high ) diff --git a/blk/431 b/blk/431 index 60f0030..f34b504 100644 --- a/blk/431 +++ b/blk/431 @@ -1,14 +1,13 @@ -( LITN has to be defined after the last immediate usage of - it to avoid bootstrapping issues ) -: LITN 32 , , ( 32 == NUMBER ) ; - -: IMMED? 1- C@ 0x80 AND ; - -( ';' can't have its name right away because, when created, it - is not an IMMEDIATE yet and will not be treated properly by - xcomp. ) -: _ - ['] EXIT , - R> DROP ( exit : ) -; IMMEDIATE +: .2 DUP 10 < IF SPC THEN . ; +: EOL? ( c -- f ) DUP 0xd = SWAP NOT OR ; +: LIST + BLK@ + 16 0 DO + I 1+ .2 SPC + 64 I * BLK( + DUP 64 + SWAP DO + I C@ DUP EOL? IF DROP LEAVE ELSE EMIT THEN + LOOP + NL + LOOP +; diff --git a/blk/432 b/blk/432 index e109431..c36efdb 100644 --- a/blk/432 +++ b/blk/432 @@ -1,16 +1,16 @@ -XCURRENT @ ( to PSP ) -: : - (entry) - ( We cannot use LITN as IMMEDIATE because of bootstrapping - issues. Same thing for ",". - 32 == NUMBER 14 == compiledWord ) - [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, - BEGIN - WORD - (find) - ( is word ) - IF DUP IMMED? IF EXECUTE ELSE , THEN - ( maybe number ) - ELSE (parse) LITN THEN - AGAIN ; -( from PSP ) ';' SWAP 4 - C! +: _ + (boot<) + DUP 4 = IF + ( We drop our char, but also "a" from WORD: it won't + have the opportunity to balance PSP because we're + EXIT!ing. ) + 2DROP + ( We're finished interpreting ) + EXIT! + THEN +; +XCURRENT @ _xapply ( to PSP, for LOAD ) +( pre-comment for tight LOAD: The 0x08==I check after INTERPRET + is to check whether we're restoring to "_", the word above. + if yes, then we're in a nested load. Also, the 1 in 0x06 is + to avoid tons of "ok" displays. ) diff --git a/blk/458 b/blk/433 similarity index 82% rename from blk/458 rename to blk/433 index f8cdec7..fa14c65 100644 --- a/blk/458 +++ b/blk/433 @@ -1,11 +1,11 @@ : LOAD BLK> @ >R ( save restorable variables to RSP ) - 0x08 RAM+ @ >R + 0x08 RAM+ @ >R ( 08 == C<* override ) 0x06 RAM+ @ >R ( CR ( boot ptr ) BLK@ BLK( 0x2e RAM+ ! ( Point to beginning of BLK ) - ['] _ 0x08 RAM+ ! ( 08 == C<* override ) + [ LITN ( from PSP, B432 ) ] 0x08 RAM+ ! 1 0x06 RAM+ ! ( 06 == C 0x2e RAM+ ! R> 0x06 RAM+ ! diff --git a/blk/459 b/blk/434 similarity index 100% rename from blk/459 rename to blk/434 diff --git a/blk/435 b/blk/435 new file mode 100644 index 0000000..60f0030 --- /dev/null +++ b/blk/435 @@ -0,0 +1,14 @@ +( LITN has to be defined after the last immediate usage of + it to avoid bootstrapping issues ) +: LITN 32 , , ( 32 == NUMBER ) ; + +: IMMED? 1- C@ 0x80 AND ; + +( ';' can't have its name right away because, when created, it + is not an IMMEDIATE yet and will not be treated properly by + xcomp. ) +: _ + ['] EXIT , + R> DROP ( exit : ) +; IMMEDIATE + diff --git a/blk/436 b/blk/436 new file mode 100644 index 0000000..e109431 --- /dev/null +++ b/blk/436 @@ -0,0 +1,16 @@ +XCURRENT @ ( to PSP ) +: : + (entry) + ( We cannot use LITN as IMMEDIATE because of bootstrapping + issues. Same thing for ",". + 32 == NUMBER 14 == compiledWord ) + [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, + BEGIN + WORD + (find) + ( is word ) + IF DUP IMMED? IF EXECUTE ELSE , THEN + ( maybe number ) + ELSE (parse) LITN THEN + AGAIN ; +( from PSP ) ';' SWAP 4 - C! diff --git a/blk/446 b/blk/446 index c2c4955..c6854e2 100644 --- a/blk/446 +++ b/blk/446 @@ -1,12 +1,3 @@ -( Drop RSP until I-2 == INTERPRET. ) -: EXIT! - ['] INTERPRET ( I ) - BEGIN ( I ) - DUP ( I I ) - R> DROP I 2- @ ( I I a ) - = UNTIL - DROP -; : (ok) SPC ." ok" NL ; : (uflw) ABORT" stack underflow" ; : (wnf) (print) SPC ABORT" word not found" ; diff --git a/blk/456 b/blk/456 deleted file mode 100644 index f34b504..0000000 --- a/blk/456 +++ /dev/null @@ -1,13 +0,0 @@ -: .2 DUP 10 < IF SPC THEN . ; -: EOL? ( c -- f ) DUP 0xd = SWAP NOT OR ; -: LIST - BLK@ - 16 0 DO - I 1+ .2 SPC - 64 I * BLK( + DUP 64 + SWAP DO - I C@ DUP EOL? IF DROP LEAVE ELSE EMIT THEN - LOOP - NL - LOOP -; - diff --git a/blk/457 b/blk/457 deleted file mode 100644 index e53efae..0000000 --- a/blk/457 +++ /dev/null @@ -1,16 +0,0 @@ -: _ - (boot<) - DUP 4 = IF - ( We drop our char, but also "a" from WORD: it won't - have the opportunity to balance PSP because we're - EXIT!ing. ) - 2DROP - ( We're finished interpreting ) - EXIT! - THEN -; - -( pre-comment for tight LOAD: The 0x08==I check after INTERPRET - is to check whether we're restoring to "_", the word above. - if yes, then we're in a nested load. Also, the 1 in 0x06 is - to avoid tons of "ok" displays. ) diff --git a/emul/forth.bin b/emul/forth.bin index 79cdcc5557b9e536a55bc4f01ccfcef3c1fce1ee..ae9856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 8 + ! ," CURRENT @ HERE ! " -440 459 XPACKR +440 446 XPACKR ," ' (key) 12 RAM+ ! " ORG @ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/rc2014/sdcard/README.md b/recipes/rc2014/sdcard/README.md index 3bc3838..f9a316c 100644 --- a/recipes/rc2014/sdcard/README.md +++ b/recipes/rc2014/sdcard/README.md @@ -19,7 +19,6 @@ design. ## Gathering parts * A RC2014 Classic -* `stage2.bin` from the base recipe * A MicroSD breakout board. I use Adafruit's. * A proto board + header pins with 39 positions so we can make a RC2014 card. * Diodes, resistors and stuff @@ -69,12 +68,30 @@ matter. However, it *does* matter for the `SELECT` line, so I don't follow my own schematic with regards to the `M1` and `A2` lines and use two inverters instead. -## Building your stage 3 +## Building your binary -Using the same technique as you used in the `eeprom` recipe, you can append -required words to your boot binary. There's only one required unit: `blk` from -core words (B453). The SD card driver was already included in the base recipe -to save you the troubles of rebuilding from stage 1 for this recipe. +Your Collapse OS binary needs the SDC drivers which need to be inserted during +Cross Compilation, which needs you need to recompile it from stage 1. First, +look at B370. You'll see that it indicates a block range for the driver. That +needs to be loaded. + +Open xcomp.fs from base recipe and locate acia loading. You'll insert a line +right after that that will look like: + + 372 387 LOADR ( sdc ) + +Normally, that's all you need to do. However, you have a little problem: You're +busting the 8K ROM limit. But it's ok, you can remove the linker's XPACKing +line: because you'll have access to the blkfs from SD card, you can load it +from there! + +Removing the linker from XPACKing will free enough space for your binary to fit +in 8K. You also have to add `BLK$` to initialization routine. + +Build it and write it to EEPROM. + +If you want, once you're all set with the SD card, you can relink core words +like you did in the base recipe for optimal resource usage. ## Testing in the emulator diff --git a/recipes/rc2014/xcomp.fs b/recipes/rc2014/xcomp.fs index b9301f2..ab5c42f 100644 --- a/recipes/rc2014/xcomp.fs +++ b/recipes/rc2014/xcomp.fs @@ -22,12 +22,11 @@ CURRENT @ XCURRENT ! 282 LOAD ( boot.z80 ) 393 LOAD ( xcomp core low ) 352 LOAD ( acia ) -372 381 LOADR ( sdc ) 420 LOAD ( xcomp core high ) (entry) _ ( Update LATEST ) PC ORG @ 8 + ! -440 452 XPACKR ( core ) +440 446 XPACKR ( core ) 123 132 XPACKR ( linker ) ," : _ ACIA$ RDLN$ (ok) ; _ " ORG @ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/ti84/xcomp.fs b/recipes/ti84/xcomp.fs index 9652539..b3da866 100644 --- a/recipes/ti84/xcomp.fs +++ b/recipes/ti84/xcomp.fs @@ -74,7 +74,7 @@ CREATE ~FNT CPFNT3x5 (entry) _ ( Update LATEST ) PC ORG @ 8 + ! -440 451 XPACKR ( core ) +440 446 XPACKR ( core ) ," : _ LCD$ KBD$ (ok) RDLN$ ; _ " ORG @ 0x100 - 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC! diff --git a/recipes/trs80/xcomp.fs b/recipes/trs80/xcomp.fs index c55d982..da36a54 100644 --- a/recipes/trs80/xcomp.fs +++ b/recipes/trs80/xcomp.fs @@ -21,7 +21,7 @@ CURRENT @ XCURRENT ! ( Update LATEST ) PC ORG @ 8 + ! ," CURRENT @ HERE ! " -440 459 XPACKR ( core ) +440 446 XPACKR ( core ) 499 500 XPACKR ( trs80.fs ) ( 0x0a == NLPTR. TRS-80 wants CR-only newlines ) ," : _ ['] CR 0x0a RAM+ ! BLK$ FD$ (ok) RDLN$ ; _ "