Compare commits

..

5 Commits

Author SHA1 Message Date
Virgil Dupras
bd1e76ec5b Gather all RC2014 drivers into a single "RC2014 Recipe section" 2020-05-13 14:56:38 -04:00
Virgil Dupras
9b85961093 Rename "Core words" to "XPACKed core"
Now that this section is so small, I think I can see a possibility
for cross-compiling Collapse OS entirely, which would be great
because we could get rid of the relinker.
2020-05-13 14:31:56 -04:00
Virgil Dupras
76037ca1e7 Simplify boot process
That INIT thing is unnecessary.
2020-05-13 14:19:54 -04:00
Virgil Dupras
bb77cd0759 xcomp: add overrides into a loadable block
Makes xcomp.fs units shorter.
2020-05-13 13:33:24 -04:00
Virgil Dupras
0434d02818 xcomp: implement X['] 2020-05-13 13:24:58 -04:00
48 changed files with 76 additions and 103 deletions

View File

@ -5,11 +5,10 @@ MASTER INDEX
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 Cross-compiled core
439 Core words 480 AT28 Driver
280 Z80 boot code 390 Cross-compiled core
439 XPACKed core
490 TRS-80 Recipe 520 Fonts
550 TI-84+ Recipe
550 TI-84+ Recipe 580 RC2014 Recipe

14
blk/089
View File

@ -1,16 +1,16 @@
Initialization sequence
On boot, we jump to the "main" routine in boot.fs which does
On boot, we jump to the "main" routine in B289 which does
very few things.
1. Set SP to 0x10000-6
1. Set SP to PS_ADDR and IX to RS_ADDR
2. Sets HERE to RAMEND (RAMSTART+0x80).
3. Sets CURRENT to value of LATEST field in stable ABI.
4. Look for the word "BOOT" and calls it.
In a normal system, BOOT is in icore and does a few things:
In a normal system, BOOT is in xcomp core (B411) and does a
few things:
1. Find "(c<)" a set CINPTR to it (what C< calls).
2. Initialize all overrides to 0.
3. Write LATEST in BOOT C< PTR ( see below )
4. Find "INIT". If found, execute. Otherwise, "INTERPRET"(cont)
1. Initialize all overrides to 0.
2. Write LATEST in BOOT C< PTR ( see below )
3. Set "C<*", the word that C< calls to (boot<). (cont.)

27
blk/090
View File

@ -1,16 +1,15 @@
On a bare system (only boot+icore), this sequence will result
in (c<) reading characters from memory starting from CURRENT
(this is why we put CURRENT in BOOT C< PTR, it tracks current
pos ).
4. Call INTERPRET
This means that you can put initialization code in source form
right into your binary, right after your last compiled dict
entry and it's going to be executed as such until you set a new
(c<).
In other words, BOOT interprets bytes directly following
CURRENT as Forth source code. This code will typically
initialize all subsystems and then call RDLN$. As soon as
this is called, INTERPRET will begin reading from RDLN< which
reads from KEY.
Note that there is no EMIT in a bare system. You have to take
care of supplying one before your load core.fs and its higher
levels.
(cont.)
In the "/emul" binaries, "HERE" is readjusted to "CURRENT @" so
that we don't have to relocate compiled dicts. Note that in
this context, the initialization code is fighting for space
with HERE: New entries to the dict will overwrite that code!
Also, because we're barebone, we can't have comments. This can
lead to peculiar code in this area where we try to "waste"
space in initialization code.

16
blk/091
View File

@ -1,16 +0,0 @@
(cont.) In the "/emul" binaries, "HERE" is readjusted to
"CURRENT @" so that we don't have to relocate compiled dicts.
Note that in this context, the initialization code is fighting
for space with HERE: New entries to the dict will overwrite
that code! Also, because we're barebone, we can't have
comments. This can lead to peculiar code in this area where we
try to "waste" space in initialization code.

View File

@ -2,7 +2,7 @@ Cross compilation program
This programs allows cross compilation of boot binary and
icore. Run "262 LOAD" right before your cross compilation and
then set XCURRENT to CURRENT.
then "270 LOAD" to apply xcomp overrides.
This unit depends on a properly initialized z80a with ORG and
BIN( set. That is how we determine compilation offsets.

View File

@ -9,6 +9,7 @@ VARIABLE XCURRENT
: XIMM XCON IMMEDIATE XCOFF ;
: _xapply ( a -- a-off )
DUP ORG @ > IF ORG @ - BIN( @ + THEN ;
: X['] XCON ' _xapply LITA XCOFF ;
: XCOMPILE
XCON ' _xapply LITA
LIT< , (find) DROP _xapply , XCOFF ;

11
blk/270 Normal file
View File

@ -0,0 +1,11 @@
: CODE XCODE ;
: ['] X['] ; IMMEDIATE
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: CREATE XCREATE ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !

View File

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

View File

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

View File

@ -6,10 +6,9 @@
0 0x55 RAM+ ! ( 55 == (key) override )
0 0x0a RAM+ ! ( NLPTR )
( 0c == C<* )
LIT< (boot<) (find) DROP 0x0c RAM+ !
['] (boot<) 0x0c RAM+ !
( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ !
LIT< INIT (find)
IF EXECUTE ELSE DROP INTERPRET THEN
INTERPRET
;

View File

@ -6,7 +6,7 @@
the last typed 0x0a and one for the following NULL. )
IN) IN> - 2+ ALLOT
(infl)
LIT< RDLN< (find) DROP 0x0c RAM+ !
['] RDLN< 0x0c RAM+ !
1 0x06 RAM+ ! ( 06 == C<? )
;

View File

@ -9,7 +9,6 @@
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

View File

@ -5,7 +5,7 @@
0x2e RAM+ @ >R ( boot ptr )
BLK@
BLK( 0x2e RAM+ ! ( Point to beginning of BLK )
[ LITN ( from PSP, B432 ) ] 0x08 RAM+ !
['] _ 0x08 RAM+ !
1 0x06 RAM+ ! ( 06 == C<? )
INTERPRET
R> 0x2e RAM+ ! R> 0x06 RAM+ !

22
blk/439
View File

@ -1,12 +1,14 @@
Core words
XPACKed core
These words follow cross-compiled words, but unlike them, these
are self-bootstrapping and don't depend on the Cross Compiler.
They will typically be included in source form right after a
stage1 binary which will interpret it on boot and bootstrap
itself to a full intepreter, which can then be relinked with
the Relinker. There is no loader for these libraries because
you will typically XPACK (B267) them.
Most of Collapse OS' core words are cross compiled (B390).
However, some of them are too dynamically referenced to be
cross-compiled without great pain, so we XPACK (B267) them,
that is, we put them in source form in the target's
initialization section (see B89).
440 core 447 readln
453 blk
These words will be compiled into RAM at initialization, which
is a bit wasteful both in RAM and in boot time, so we will
typically relink (B120) that newly compiled binary and append
it to our existing binary for optimal resource usage.
Load range: 440-446

7
blk/580 Normal file
View File

@ -0,0 +1,7 @@
RC2014 Recipe
Support code for the RC2014 recipe. Contains drivers for the
ACIA, SD card and AT28 EEPROM.
581 ACIA 590 AT28 EEPROM
600 SD card

View File

@ -13,4 +13,4 @@ ACIA_MEM: Address in memory that can be used variables shared
with ACIA's native words. 8 bytes used.
The whole driver is cross-compilable and is loaded with
"352 LOAD"
"582 LOAD"

View File

View File

View File

View File

View File

View File

View File

View File

@ -3,4 +3,4 @@ AT28 Driver
Write to an AT28 EEPROM while making sure that proper timing
is followed and verify data integrity.
Load with "481 LOAD"
Load with "591 LOAD"

View File

3
blk/600 Normal file
View File

@ -0,0 +1,3 @@
SD Card driver
Load range: 602-616

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

Binary file not shown.

View File

@ -20,9 +20,9 @@
RDLN$
LIT< _sys [entry]
." Collapse OS" NL
INTERPRET
;
(entry) _
H@ 256 /MOD 2 PC! 2 PC!
H@ 0x08 BIN+ ! ( update LATEST )
," INIT "
H@ 256 /MOD 2 PC! 2 PC!

View File

@ -3,14 +3,7 @@
0xfffa CONSTANT PS_ADDR
212 LOAD ( z80 assembler )
262 LOAD ( xcomp )
: CODE XCODE ;
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !
270 LOAD ( xcomp overrides )
282 LOAD ( boot.z80 )
393 LOAD ( xcomp core low )

View File

@ -46,7 +46,7 @@ Addressed devices are at B140. To know what you have to paste, open the loader
block (B142) and see what blocks it loads. For each of the blocks, copy/paste
the code in your interpreter.
Do the same thing with the AT28 driver (B480)
Do the same thing with the AT28 driver (B590)
If you're doing the real thing and not using the emulator, pasting so much code
at once might freeze up the RC2014, so it is recommended that you use

View File

@ -72,13 +72,13 @@ instead.
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
look at B600. 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 )
602 616 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

View File

@ -9,19 +9,11 @@
RAMSTART 0x70 + CONSTANT ACIA_MEM
212 LOAD ( z80 assembler )
262 LOAD ( xcomp )
: CODE XCODE ;
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: CREATE XCREATE ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !
270 LOAD ( xcomp overrides )
282 LOAD ( boot.z80 )
393 LOAD ( xcomp core low )
352 LOAD ( acia )
582 LOAD ( acia )
420 LOAD ( xcomp core high )
(entry) _
( Update LATEST )

View File

@ -8,13 +8,7 @@ RAMSTART 0x72 + CONSTANT KBD_MEM
: ZFILL, ( u ) 0 DO 0 A, LOOP ;
262 LOAD ( xcomp )
522 LOAD ( font compiler )
: CODE XCODE ;
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: CREATE XCREATE ; ( for KBD tbls )
: : [ ' X: , ] ;
270 LOAD ( xcomp overrides )
( TI-84+ requires specific code at specific offsets which
come in conflict with Collapse OS' stable ABI. We thus

View File

@ -3,14 +3,7 @@
RS_ADDR 0x80 - CONSTANT RAMSTART
212 LOAD ( z80 assembler )
262 LOAD ( xcomp )
: CODE XCODE ;
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !
270 LOAD ( xcomp overrides )
0x3000 BIN( !
282 LOAD ( boot.z80 )