Move core's blk to xcomp core (low and high)

TODO: implement X['] so that I can remove those XCURRENT patterns.
This commit is contained in:
Virgil Dupras 2020-05-13 10:14:23 -04:00
parent d956386e9b
commit 7c20501f27
23 changed files with 103 additions and 89 deletions

View File

@ -1,9 +1,9 @@
( Relink a regular Forth full interpreter. ) ( Relink a regular Forth full interpreter. )
: RLCORE : RLCORE
LIT< H@ (find) DROP ( target ) LIT< [ (find) DROP ( target )
DUP 3 - @ ( t prevoff ) DUP 3 - @ ( t prevoff )
( subtract H@ name length ) ( subtract [ name length )
2- ( t o ) 1- ( t o )
RLDICT RLDICT
; ;

View File

@ -1,3 +1,3 @@
SD Card driver SD Card driver
Load range: 372-381 Load range: 372-387

View File

@ -12,4 +12,4 @@
0 0x08 RAM+ ! ( 08 == C<* override ) 0 0x08 RAM+ ! ( 08 == C<* override )
LIT< INTERPRET (find) DROP EXECUTE LIT< INTERPRET (find) DROP EXECUTE
; ;
1 22 LOADR+ 1 25 LOADR+ ( xcomp core low )

13
blk/409
View File

@ -4,6 +4,13 @@
(find) (find)
NOT IF (parse) ELSE EXECUTE THEN NOT IF (parse) ELSE EXECUTE THEN
C<? NOT IF LIT< (ok) (find) IF EXECUTE THEN THEN C<? NOT IF LIT< (ok) (find) IF EXECUTE THEN THEN
AGAIN AGAIN ;
; XCURRENT @ _xapply ( to PSP )
( Drop RSP until I-2 == INTERPRET. )
: EXIT!
[ LITN ] ( I, from PSP )
BEGIN ( I )
DUP ( I I )
R> DROP I 2- @ ( I I a )
= UNTIL
DROP ;

View File

View File

View File

View File

@ -1 +1 @@
1 12 LOADR+ ( xcomp core high ) 1 16 LOADR+ ( xcomp core high )

25
blk/431
View File

@ -1,14 +1,13 @@
( LITN has to be defined after the last immediate usage of : .2 DUP 10 < IF SPC THEN . ;
it to avoid bootstrapping issues ) : EOL? ( c -- f ) DUP 0xd = SWAP NOT OR ;
: LITN 32 , , ( 32 == NUMBER ) ; : LIST
BLK@
: IMMED? 1- C@ 0x80 AND ; 16 0 DO
I 1+ .2 SPC
( ';' can't have its name right away because, when created, it 64 I * BLK( + DUP 64 + SWAP DO
is not an IMMEDIATE yet and will not be treated properly by I C@ DUP EOL? IF DROP LEAVE ELSE EMIT THEN
xcomp. ) LOOP
: _ NL
['] EXIT , LOOP
R> DROP ( exit : ) ;
; IMMEDIATE

32
blk/432
View File

@ -1,16 +1,16 @@
XCURRENT @ ( to PSP ) : _
: : (boot<)
(entry) DUP 4 = IF
( We cannot use LITN as IMMEDIATE because of bootstrapping ( We drop our char, but also "a" from WORD: it won't
issues. Same thing for ",". have the opportunity to balance PSP because we're
32 == NUMBER 14 == compiledWord ) EXIT!ing. )
[ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, 2DROP
BEGIN ( We're finished interpreting )
WORD EXIT!
(find) THEN
( is word ) ;
IF DUP IMMED? IF EXECUTE ELSE , THEN XCURRENT @ _xapply ( to PSP, for LOAD )
( maybe number ) ( pre-comment for tight LOAD: The 0x08==I check after INTERPRET
ELSE (parse) LITN THEN is to check whether we're restoring to "_", the word above.
AGAIN ; if yes, then we're in a nested load. Also, the 1 in 0x06 is
( from PSP ) ';' SWAP 4 - C! to avoid tons of "ok" displays. )

View File

@ -1,11 +1,11 @@
: LOAD : LOAD
BLK> @ >R ( save restorable variables to RSP ) BLK> @ >R ( save restorable variables to RSP )
0x08 RAM+ @ >R 0x08 RAM+ @ >R ( 08 == C<* override )
0x06 RAM+ @ >R ( C<? ) 0x06 RAM+ @ >R ( C<? )
0x2e RAM+ @ >R ( boot ptr ) 0x2e RAM+ @ >R ( boot ptr )
BLK@ BLK@
BLK( 0x2e RAM+ ! ( Point to beginning of 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<? ) 1 0x06 RAM+ ! ( 06 == C<? )
INTERPRET INTERPRET
R> 0x2e RAM+ ! R> 0x06 RAM+ ! R> 0x2e RAM+ ! R> 0x06 RAM+ !

View File

14
blk/435 Normal file
View File

@ -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

16
blk/436 Normal file
View File

@ -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!

View File

@ -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 ; : (ok) SPC ." ok" NL ;
: (uflw) ABORT" stack underflow" ; : (uflw) ABORT" stack underflow" ;
: (wnf) (print) SPC ABORT" word not found" ; : (wnf) (print) SPC ABORT" word not found" ;

13
blk/456
View File

@ -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
;

16
blk/457
View File

@ -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. )

Binary file not shown.

View File

@ -21,7 +21,7 @@ CURRENT @ XCURRENT !
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
," CURRENT @ HERE ! " ," CURRENT @ HERE ! "
440 459 XPACKR 440 446 XPACKR
," ' (key) 12 RAM+ ! " ," ' (key) 12 RAM+ ! "
ORG @ 256 /MOD 2 PC! 2 PC! ORG @ 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!

View File

@ -19,7 +19,6 @@ design.
## Gathering parts ## Gathering parts
* A RC2014 Classic * A RC2014 Classic
* `stage2.bin` from the base recipe
* A MicroSD breakout board. I use Adafruit's. * A MicroSD breakout board. I use Adafruit's.
* A proto board + header pins with 39 positions so we can make a RC2014 card. * A proto board + header pins with 39 positions so we can make a RC2014 card.
* Diodes, resistors and stuff * 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 own schematic with regards to the `M1` and `A2` lines and use two inverters
instead. instead.
## Building your stage 3 ## Building your binary
Using the same technique as you used in the `eeprom` recipe, you can append Your Collapse OS binary needs the SDC drivers which need to be inserted during
required words to your boot binary. There's only one required unit: `blk` from Cross Compilation, which needs you need to recompile it from stage 1. First,
core words (B453). The SD card driver was already included in the base recipe look at B370. You'll see that it indicates a block range for the driver. That
to save you the troubles of rebuilding from stage 1 for this recipe. 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 ## Testing in the emulator

View File

@ -22,12 +22,11 @@ CURRENT @ XCURRENT !
282 LOAD ( boot.z80 ) 282 LOAD ( boot.z80 )
393 LOAD ( xcomp core low ) 393 LOAD ( xcomp core low )
352 LOAD ( acia ) 352 LOAD ( acia )
372 381 LOADR ( sdc )
420 LOAD ( xcomp core high ) 420 LOAD ( xcomp core high )
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
440 452 XPACKR ( core ) 440 446 XPACKR ( core )
123 132 XPACKR ( linker ) 123 132 XPACKR ( linker )
," : _ ACIA$ RDLN$ (ok) ; _ " ," : _ ACIA$ RDLN$ (ok) ; _ "
ORG @ 256 /MOD 2 PC! 2 PC! ORG @ 256 /MOD 2 PC! 2 PC!

View File

@ -74,7 +74,7 @@ CREATE ~FNT CPFNT3x5
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
440 451 XPACKR ( core ) 440 446 XPACKR ( core )
," : _ LCD$ KBD$ (ok) RDLN$ ; _ " ," : _ LCD$ KBD$ (ok) RDLN$ ; _ "
ORG @ 0x100 - 256 /MOD 2 PC! 2 PC! ORG @ 0x100 - 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!

View File

@ -21,7 +21,7 @@ CURRENT @ XCURRENT !
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
," CURRENT @ HERE ! " ," CURRENT @ HERE ! "
440 459 XPACKR ( core ) 440 446 XPACKR ( core )
499 500 XPACKR ( trs80.fs ) 499 500 XPACKR ( trs80.fs )
( 0x0a == NLPTR. TRS-80 wants CR-only newlines ) ( 0x0a == NLPTR. TRS-80 wants CR-only newlines )
," : _ ['] CR 0x0a RAM+ ! BLK$ FD$ (ok) RDLN$ ; _ " ," : _ ['] CR 0x0a RAM+ ! BLK$ FD$ (ok) RDLN$ ; _ "