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 79cdcc5..ae9856c 100644 Binary files a/emul/forth.bin and b/emul/forth.bin differ diff --git a/emul/xcomp.fs b/emul/xcomp.fs index 02d7251..5d62af7 100644 --- a/emul/xcomp.fs +++ b/emul/xcomp.fs @@ -21,7 +21,7 @@ CURRENT @ XCURRENT ! ( Update LATEST ) PC ORG @ 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$ ; _ "