浏览代码

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

TODO: implement X['] so that I can remove those XCURRENT patterns.
pull/102/head
Virgil Dupras 4 年前
父节点
当前提交
7c20501f27
共有 23 个文件被更改,包括 103 次插入89 次删除
  1. +3
    -3
      blk/131
  2. +1
    -1
      blk/370
  3. +1
    -1
      blk/393
  4. +10
    -3
      blk/409
  5. +0
    -0
      blk/416
  6. +0
    -0
      blk/417
  7. +0
    -0
      blk/418
  8. +1
    -1
      blk/420
  9. +12
    -13
      blk/431
  10. +16
    -16
      blk/432
  11. +2
    -2
      blk/433
  12. +0
    -0
      blk/434
  13. +14
    -0
      blk/435
  14. +16
    -0
      blk/436
  15. +0
    -9
      blk/446
  16. +0
    -13
      blk/456
  17. +0
    -16
      blk/457
  18. 二进制
      emul/forth.bin
  19. +1
    -1
      emul/xcomp.fs
  20. +23
    -6
      recipes/rc2014/sdcard/README.md
  21. +1
    -2
      recipes/rc2014/xcomp.fs
  22. +1
    -1
      recipes/ti84/xcomp.fs
  23. +1
    -1
      recipes/trs80/xcomp.fs

+ 3
- 3
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
;


+ 1
- 1
blk/370 查看文件

@@ -1,3 +1,3 @@
SD Card driver

Load range: 372-381
Load range: 372-387

+ 1
- 1
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 )

+ 10
- 3
blk/409 查看文件

@@ -4,6 +4,13 @@
(find)
NOT IF (parse) ELSE EXECUTE 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 ;

blk/453 → blk/416 查看文件


blk/454 → blk/417 查看文件


blk/455 → blk/418 查看文件


+ 1
- 1
blk/420 查看文件

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

+ 12
- 13
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
;


+ 16
- 16
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. )

blk/458 → 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 ( C<? )
0x2e RAM+ @ >R ( 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<? )
INTERPRET
R> 0x2e RAM+ ! R> 0x06 RAM+ !

blk/459 → blk/434 查看文件


+ 14
- 0
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


+ 16
- 0
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!

+ 0
- 9
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" ;

+ 0
- 13
blk/456 查看文件

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


+ 0
- 16
blk/457 查看文件

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

二进制
emul/forth.bin 查看文件


+ 1
- 1
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!

+ 23
- 6
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



+ 1
- 2
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!


+ 1
- 1
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!

+ 1
- 1
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$ ; _ "


正在加载...
取消
保存