1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 06:40:56 +11:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Virgil Dupras
33d37d4ce9 WORD: don't overwrite RAM on words over 31 chars
This allows me to reclaim some RAM I hadn't even noticed I
needlessly monopolise.
2020-05-13 20:39:53 -04:00
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
51 changed files with 80 additions and 109 deletions

View File

@ -5,11 +5,10 @@ MASTER INDEX
120 Linker 140 Addressed devices 120 Linker 140 Addressed devices
150 Extra words 150 Extra words
200 Z80 assembler 260 Cross compilation 200 Z80 assembler 260 Cross compilation
280 Z80 boot code 350 ACIA driver 280 Z80 boot code 390 Cross-compiled core
370 SD Card driver 390 Cross-compiled core 439 XPACKed core
439 Core words 480 AT28 Driver
490 TRS-80 Recipe 520 Fonts 490 TRS-80 Recipe 520 Fonts
550 TI-84+ Recipe 550 TI-84+ Recipe 580 RC2014 Recipe

View File

@ -7,6 +7,7 @@ RAMSTART FUTURE USES +55 (key) override
+0c C<* +70 DRIVERS +0c C<* +70 DRIVERS
+0e WORDBUF +80 RAMEND +0e WORDBUF +80 RAMEND
+2e BOOT C< PTR +2e BOOT C< PTR
+30 FUTURE USES
+4e INTJUMP +4e INTJUMP
+51 CURRENTPTR +51 CURRENTPTR
+53 (emit) override +53 (emit) override

14
blk/089
View File

@ -1,16 +1,16 @@
Initialization sequence 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. 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). 2. Sets HERE to RAMEND (RAMSTART+0x80).
3. Sets CURRENT to value of LATEST field in stable ABI. 3. Sets CURRENT to value of LATEST field in stable ABI.
4. Look for the word "BOOT" and calls it. 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). 1. Initialize all overrides to 0.
2. Initialize all overrides to 0. 2. Write LATEST in BOOT C< PTR ( see below )
3. Write LATEST in BOOT C< PTR ( see below ) 3. Set "C<*", the word that C< calls to (boot<). (cont.)
4. Find "INIT". If found, execute. Otherwise, "INTERPRET"(cont)

27
blk/090
View File

@ -1,16 +1,15 @@
On a bare system (only boot+icore), this sequence will result 4. Call INTERPRET
in (c<) reading characters from memory starting from CURRENT
(this is why we put CURRENT in BOOT C< PTR, it tracks current
pos ).
This means that you can put initialization code in source form In other words, BOOT interprets bytes directly following
right into your binary, right after your last compiled dict CURRENT as Forth source code. This code will typically
entry and it's going to be executed as such until you set a new initialize all subsystems and then call RDLN$. As soon as
(c<). 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 In the "/emul" binaries, "HERE" is readjusted to "CURRENT @" so
care of supplying one before your load core.fs and its higher that we don't have to relocate compiled dicts. Note that in
levels. 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
(cont.) 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 This programs allows cross compilation of boot binary and
icore. Run "262 LOAD" right before your cross compilation 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 This unit depends on a properly initialized z80a with ORG and
BIN( set. That is how we determine compilation offsets. BIN( set. That is how we determine compilation offsets.

View File

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

@ -1,7 +1,4 @@
( The NOT is to normalize the negative/positive numbers to 1 : WS? 33 < ;
or 0. Hadn't we wanted to normalize, we'd have written:
32 CMP 1 - )
: WS? 33 CMP 1+ NOT ;
: TOWORD : TOWORD
BEGIN BEGIN

View File

@ -1,5 +1,5 @@
( Read word from C<, copy to WORDBUF, null-terminate, and ( Read word from C<, copy to WORDBUF, null-terminate, and
return, make HL point to WORDBUF. ) return WORDBUF. )
: WORD : WORD
0x0e RAM+ ( 0e == WORDBUF ) 0x0e RAM+ ( 0e == WORDBUF )
TOWORD ( a c ) TOWORD ( a c )
@ -8,7 +8,7 @@
always zero to pre-write our null-termination ) always zero to pre-write our null-termination )
OVER ! 1+ ( a+1 ) OVER ! 1+ ( a+1 )
C< ( a c ) C< ( a c )
DUP WS? OVER 0x2d ( 2e-1 for NULL ) RAM+ = OVER WS? OR
UNTIL UNTIL
( a this point, PS is: a WS ) ( a this point, PS is: a WS )
( null-termination is already written ) ( null-termination is already written )

View File

@ -5,10 +5,10 @@
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. ) ( Drop RSP until I-2 == INTERPRET. )
: EXIT! : EXIT!
[ LITN ] ( I, from PSP ) ['] INTERPRET ( I )
BEGIN ( I ) BEGIN ( I )
DUP ( I I ) DUP ( I I )
R> DROP I 2- @ ( I I a ) R> DROP I 2- @ ( I I a )

View File

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

View File

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

View File

@ -9,7 +9,6 @@
EXIT! EXIT!
THEN THEN
; ;
XCURRENT @ _xapply ( to PSP, for LOAD )
( pre-comment for tight LOAD: The 0x08==I check after INTERPRET ( pre-comment for tight LOAD: The 0x08==I check after INTERPRET
is to check whether we're restoring to "_", the word above. 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 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 ) 0x2e RAM+ @ >R ( boot ptr )
BLK@ BLK@
BLK( 0x2e RAM+ ! ( Point to beginning of BLK ) BLK( 0x2e RAM+ ! ( Point to beginning of BLK )
[ LITN ( from PSP, B432 ) ] 0x08 RAM+ ! ['] _ 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+ !

22
blk/439
View File

@ -1,12 +1,14 @@
Core words XPACKed core
These words follow cross-compiled words, but unlike them, these Most of Collapse OS' core words are cross compiled (B390).
are self-bootstrapping and don't depend on the Cross Compiler. However, some of them are too dynamically referenced to be
They will typically be included in source form right after a cross-compiled without great pain, so we XPACK (B267) them,
stage1 binary which will interpret it on boot and bootstrap that is, we put them in source form in the target's
itself to a full intepreter, which can then be relinked with initialization section (see B89).
the Relinker. There is no loader for these libraries because
you will typically XPACK (B267) them.
440 core 447 readln These words will be compiled into RAM at initialization, which
453 blk 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. with ACIA's native words. 8 bytes used.
The whole driver is cross-compilable and is loaded with 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 Write to an AT28 EEPROM while making sure that proper timing
is followed and verify data integrity. 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$ RDLN$
LIT< _sys [entry] LIT< _sys [entry]
." Collapse OS" NL ." Collapse OS" NL
INTERPRET
; ;
(entry) _ (entry) _
H@ 256 /MOD 2 PC! 2 PC!
H@ 0x08 BIN+ ! ( update LATEST ) H@ 0x08 BIN+ ! ( update LATEST )
," INIT "
H@ 256 /MOD 2 PC! 2 PC!

View File

@ -3,14 +3,7 @@
0xfffa CONSTANT PS_ADDR 0xfffa CONSTANT PS_ADDR
212 LOAD ( z80 assembler ) 212 LOAD ( z80 assembler )
262 LOAD ( xcomp ) 262 LOAD ( xcomp )
: CODE XCODE ; 270 LOAD ( xcomp overrides )
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !
282 LOAD ( boot.z80 ) 282 LOAD ( boot.z80 )
393 LOAD ( xcomp core low ) 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 block (B142) and see what blocks it loads. For each of the blocks, copy/paste
the code in your interpreter. 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 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 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 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, 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. needs to be loaded.
Open xcomp.fs from base recipe and locate acia loading. You'll insert a line Open xcomp.fs from base recipe and locate acia loading. You'll insert a line
right after that that will look like: 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 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 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 RAMSTART 0x70 + CONSTANT ACIA_MEM
212 LOAD ( z80 assembler ) 212 LOAD ( z80 assembler )
262 LOAD ( xcomp ) 262 LOAD ( xcomp )
: CODE XCODE ; 270 LOAD ( xcomp overrides )
: COMPILE XCOMPILE ; IMMEDIATE
: [COMPILE] X[COMPILE] ; IMMEDIATE
: IMMEDIATE XIMM ;
: (entry) (xentry) ;
: CREATE XCREATE ;
: : [ ' X: , ] ;
CURRENT @ XCURRENT !
282 LOAD ( boot.z80 ) 282 LOAD ( boot.z80 )
393 LOAD ( xcomp core low ) 393 LOAD ( xcomp core low )
352 LOAD ( acia ) 582 LOAD ( acia )
420 LOAD ( xcomp core high ) 420 LOAD ( xcomp core high )
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )

View File

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

View File

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