mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 12:20:56 +11:00
Compare commits
No commits in common. "6767012ebd4841f115ba6e41c268fe8f3c1d7746" and "5219887ad7812e5b3c174999b2dc66942639fa41" have entirely different histories.
6767012ebd
...
5219887ad7
6
blk/083
6
blk/083
@ -1,6 +1,5 @@
|
|||||||
C<? is a flag indicating whether a character is waiting in the
|
C<?* is a pointer to a word being called by C<?. If 0 or 1,
|
||||||
input stream. 1 means yes, 0 means no. It is the responsibility
|
will return that value as-is.
|
||||||
of C<* to update that flag.
|
|
||||||
|
|
||||||
WORDBUF is the buffer used by WORD
|
WORDBUF is the buffer used by WORD
|
||||||
|
|
||||||
@ -13,4 +12,5 @@ jump to this address. If you use one of those slots for an
|
|||||||
interrupt, write a jump to the appropriate offset in that RAM
|
interrupt, write a jump to the appropriate offset in that RAM
|
||||||
location.
|
location.
|
||||||
|
|
||||||
|
|
||||||
(cont.)
|
(cont.)
|
||||||
|
6
blk/267
6
blk/267
@ -1,6 +0,0 @@
|
|||||||
XPACK - pack source code
|
|
||||||
|
|
||||||
The goal of this word is to pack source code in tight places,
|
|
||||||
such as on the boot section of an EEPROM. It takes a block
|
|
||||||
number, reads it and packs it to HERE. It normalizes all
|
|
||||||
whitespaces to a single space and ignore comments.
|
|
16
blk/268
16
blk/268
@ -1,16 +0,0 @@
|
|||||||
: XPACK ( blkno -- )
|
|
||||||
BLK@
|
|
||||||
BLK( 0x2e RAM+ ! ( boot ptr )
|
|
||||||
['] (boot<) 0x08 RAM+ ! ( C<* override )
|
|
||||||
BEGIN
|
|
||||||
WORD
|
|
||||||
0x2e RAM+ @ BLK( 1024 + < IF
|
|
||||||
DUP LIT< ( S= IF
|
|
||||||
DROP [COMPILE] (
|
|
||||||
ELSE
|
|
||||||
SCPY 0x20 H@ 1- C!
|
|
||||||
THEN 0 ( loop again )
|
|
||||||
ELSE 1 ( stop looping ) THEN
|
|
||||||
UNTIL
|
|
||||||
0 0x08 RAM+ !
|
|
||||||
;
|
|
2
blk/398
2
blk/398
@ -2,7 +2,7 @@
|
|||||||
for an abort message )
|
for an abort message )
|
||||||
: (parse) (parsed) NOT IF ABORT THEN ;
|
: (parse) (parsed) NOT IF ABORT THEN ;
|
||||||
|
|
||||||
: C<? 0x06 RAM+ @ ;
|
: C<? 0x06 RAM+ @ DUP 2 > IF EXECUTE THEN ( 06 == C<?* ) ;
|
||||||
: C<
|
: C<
|
||||||
0x08 RAM+ @ ( 08 == C<* override )
|
0x08 RAM+ @ ( 08 == C<* override )
|
||||||
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
|
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
|
||||||
|
BIN
emul/z80c.bin
BIN
emul/z80c.bin
Binary file not shown.
@ -61,21 +61,17 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
: LOAD
|
: LOAD
|
||||||
( save restorable variables to RSP )
|
( save BLK>, C<* override and boot< ptr to RSP )
|
||||||
BLK> @ >R
|
BLK> @ >R
|
||||||
0x08 RAM+ @ >R
|
0x08 RAM+ @ >R
|
||||||
0x06 RAM+ @ >R ( C<? )
|
0x2e RAM+ @ >R
|
||||||
0x2e RAM+ @ >R ( boot ptr )
|
|
||||||
BLK@
|
BLK@
|
||||||
( Point to beginning of BLK )
|
( Point to beginning of BLK )
|
||||||
BLK( 0x2e RAM+ !
|
BLK( 0x2e RAM+ !
|
||||||
( 08 == C<* override )
|
( 08 == C<* override )
|
||||||
['] _ 0x08 RAM+ !
|
['] _ 0x08 RAM+ !
|
||||||
( While we interpret, don't print "ok" after every word )
|
|
||||||
1 0x06 RAM+ ! ( 06 == C<? )
|
|
||||||
INTERPRET
|
INTERPRET
|
||||||
R> 0x2e RAM+ !
|
R> 0x2e RAM+ !
|
||||||
R> 0x06 RAM+ !
|
|
||||||
( Before we restore C<* are we restoring it to "_"?
|
( Before we restore C<* are we restoring it to "_"?
|
||||||
if yes, it means we're in a nested LOAD which means we
|
if yes, it means we're in a nested LOAD which means we
|
||||||
should also load back the saved BLK>. Otherwise, we can
|
should also load back the saved BLK>. Otherwise, we can
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
: BEGIN H@ ; IMMEDIATE
|
: BEGIN H@ ; IMMEDIATE
|
||||||
: AGAIN COMPILE (br) H@ - , ; IMMEDIATE
|
: AGAIN COMPILE (br) H@ - , ; IMMEDIATE
|
||||||
: UNTIL COMPILE (?br) H@ - , ; IMMEDIATE
|
: UNTIL COMPILE (?br) H@ - , ; IMMEDIATE
|
||||||
: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE
|
: ( BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE
|
||||||
40 CURRENT @ 4 - C!
|
|
||||||
( Hello, hello, krkrkrkr... do you hear me?
|
( Hello, hello, krkrkrkr... do you hear me?
|
||||||
Ah, voice at last! Some lines above need comments
|
Ah, voice at last! Some lines above need comments
|
||||||
BTW: Forth lines limited to 64 cols because of default
|
BTW: Forth lines limited to 64 cols because of default
|
||||||
@ -28,8 +27,6 @@
|
|||||||
"_": words starting with "_" are meant to be "private",
|
"_": words starting with "_" are meant to be "private",
|
||||||
that is, only used by their immediate surrondings.
|
that is, only used by their immediate surrondings.
|
||||||
|
|
||||||
40 is ASCII for '('. We do this to simplify XPACK's task of
|
|
||||||
not mistakenly consider '(' definition as a comment.
|
|
||||||
LITS: 34 == litWord
|
LITS: 34 == litWord
|
||||||
LITA: 36 == addrWord
|
LITA: 36 == addrWord
|
||||||
COMPILE: Tough one. Get addr of caller word (example above
|
COMPILE: Tough one. Get addr of caller word (example above
|
||||||
|
@ -59,18 +59,15 @@
|
|||||||
LF IN( IN> !
|
LF IN( IN> !
|
||||||
;
|
;
|
||||||
|
|
||||||
( And finally, implement C<* )
|
: RDLN<? IN> @ C@ ;
|
||||||
|
|
||||||
|
( And finally, implement a replacement for the (c<) routine )
|
||||||
: RDLN<
|
: RDLN<
|
||||||
IN> @ C@
|
RDLN<? ( c )
|
||||||
DUP IF
|
|
||||||
( not EOL? good, inc and return )
|
( not EOL? good, inc and return )
|
||||||
1 IN> +!
|
DUP IF 1 IN> +! EXIT THEN ( c )
|
||||||
ELSE
|
( EOL ? readline. we still return typed char though )
|
||||||
( EOL ? readline. we still return null though )
|
(rdln) ( c )
|
||||||
(rdln)
|
|
||||||
THEN
|
|
||||||
( update C<? flag )
|
|
||||||
IN> @ C@ 0 > 0x06 RAM+ ! ( 06 == C<? )
|
|
||||||
;
|
;
|
||||||
|
|
||||||
( Initializes the readln subsystem )
|
( Initializes the readln subsystem )
|
||||||
@ -81,7 +78,7 @@
|
|||||||
the last typed 0x0a and one for the following NULL. )
|
the last typed 0x0a and one for the following NULL. )
|
||||||
INBUFSZ 4 + ALLOT
|
INBUFSZ 4 + ALLOT
|
||||||
(infl)
|
(infl)
|
||||||
|
['] RDLN<? 0x06 RAM+ !
|
||||||
['] RDLN< 0x0c RAM+ !
|
['] RDLN< 0x0c RAM+ !
|
||||||
1 0x06 RAM+ ! ( 06 == C<? )
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ are other recipes related to the RC2014:
|
|||||||
|
|
||||||
* [Writing to a AT28 from Collapse OS](eeprom/README.md)
|
* [Writing to a AT28 from Collapse OS](eeprom/README.md)
|
||||||
* [Accessing a MicroSD card](sdcard/README.md)
|
* [Accessing a MicroSD card](sdcard/README.md)
|
||||||
* [Self-hosting](selfhost/README.md)
|
* [Assembling binaries](zasm/README.md)
|
||||||
* [Interfacing a PS/2 keyboard](ps2/README.md)
|
* [Interfacing a PS/2 keyboard](ps2/README.md)
|
||||||
|
|
||||||
## Recipe
|
## Recipe
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
: x KEY DUP EMIT ;
|
: (c<) KEY DUP EMIT ;
|
||||||
: _ ACIA$ (ok) ['] x 0x0c RAM+ ! ; _
|
: _
|
||||||
|
ACIA$
|
||||||
|
." Collapse OS" CRLF
|
||||||
|
( 0c == CINPTR )
|
||||||
|
['] (c<) 0x0c RAM+ !
|
||||||
|
; _
|
||||||
|
@ -105,11 +105,5 @@ And thats it! You have full access to disk block mechanism:
|
|||||||
|
|
||||||
(at this moment, the driver is a bit slow though...)
|
(at this moment, the driver is a bit slow though...)
|
||||||
|
|
||||||
## How do I fill my SD card with Collapse OS' FS?
|
|
||||||
|
|
||||||
Very easy. You see that `/emul/blkfs` file? You dump it to your raw device.
|
|
||||||
For example, if the device you get when you insert your SD card is `/dev/sdb`,
|
|
||||||
then you type `cat emul/blkfs | sudo tee /dev/sdb > /dev/null`.
|
|
||||||
|
|
||||||
[schematic]: spirelay/spirelay.pdf
|
[schematic]: spirelay/spirelay.pdf
|
||||||
[inspiration]: https://www.ecstaticlyrics.com/electronics/SPI/fast_z80_interface.html
|
[inspiration]: https://www.ecstaticlyrics.com/electronics/SPI/fast_z80_interface.html
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
# Assembling Collapse OS from within it
|
|
||||||
|
|
||||||
This is where we tie lose ends, complete the circle, loop the loop: we assemble
|
|
||||||
a new Collapse OS *entirely* from within Collapse OS and write it to EEPROM,
|
|
||||||
either for another RC2014 or for an OS upgrade.
|
|
||||||
|
|
||||||
## Gathering parts
|
|
||||||
|
|
||||||
* stage4 from `sdcard` recipe. If you want to write to EEPROM as the final step,
|
|
||||||
you'll need a hybrid stage4 that also includes stuff from the `eeprom` recipe.
|
|
||||||
|
|
||||||
## Building stage 1
|
|
||||||
|
|
||||||
### Part 1
|
|
||||||
|
|
||||||
Building the first part of stage 1 (the binary part, before the inlined-source
|
|
||||||
part) from within Collapse OS is actually very similar from building it from a
|
|
||||||
modern environment. If you take the time to look at the base recipe `Makefile`,
|
|
||||||
you'll see `cat xcomp.fs | $(STAGE2)`. That command builds part 1. Open
|
|
||||||
`xcomp.fs` in a text editor and take a look at it.
|
|
||||||
|
|
||||||
To assemble stage 1 from RC2014, all you need to do is to type those commands
|
|
||||||
in the same order, and replace the `H@ 256 /MOD 2 PC! 2 PC!` lines with `H@ .X`.
|
|
||||||
Those commands will inform you of the begin/end offsets of the assembled binary.
|
|
||||||
|
|
||||||
The meaning of these commands is not explained here. You are encouraged to read
|
|
||||||
the in-system documentation for more information.
|
|
||||||
|
|
||||||
However, one thing you should know is that because the SD card driver is a bit
|
|
||||||
slow, some of these commands take a long time. Multiple minutes. Be patient.
|
|
||||||
|
|
||||||
Once all your commands are run and that you have your begin/end offset (write
|
|
||||||
them down somewhere), you're ready to assemble part 2.
|
|
||||||
|
|
||||||
### What to do on SDerr?
|
|
||||||
|
|
||||||
If you get `SDerr` in the middle of a LOAD operation, something went wrong with
|
|
||||||
the SD card. The bad news is that it left your xcomp operation in an
|
|
||||||
inconsistent state. If your at the beginning of it, it's easier to restart it
|
|
||||||
entirely.
|
|
||||||
|
|
||||||
If you're towards the end, you might want to repair it. To do so, you'll have to
|
|
||||||
bring your `XCURRENT` and `HERE` values to where they were before the LOAD
|
|
||||||
operation. You could have thought ahead and printed them before the LOAD, but if
|
|
||||||
you didn't, you'll just have to dig in your memory with `DUMP`.
|
|
||||||
|
|
||||||
You're looking at the offset of the last wordref of the *previous* LOAD
|
|
||||||
operation. That offset is going in `XCURRENT`. Then, you're looking at the end
|
|
||||||
of that word. That offset goes in `HERE`. Once you've done that, relaunch your
|
|
||||||
LOAD.
|
|
||||||
|
|
||||||
### Part 2
|
|
||||||
|
|
||||||
TODO
|
|
@ -13,7 +13,7 @@ by more than once space or by a newline. Hackish, but works.
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int spccnt = 1; // if the first char is a (, consider it a comment opener.
|
int spccnt = 2; // if the first char is a (, consider it a comment opener.
|
||||||
int incomment = 0;
|
int incomment = 0;
|
||||||
int c;
|
int c;
|
||||||
c = getchar();
|
c = getchar();
|
||||||
@ -24,7 +24,7 @@ int main()
|
|||||||
// doesn't like when they're not there...
|
// doesn't like when they're not there...
|
||||||
putchar(c);
|
putchar(c);
|
||||||
}
|
}
|
||||||
spccnt += 1;
|
spccnt += 2;
|
||||||
} else if (c == ' ') {
|
} else if (c == ' ') {
|
||||||
spccnt++;
|
spccnt++;
|
||||||
} else {
|
} else {
|
||||||
@ -33,7 +33,7 @@ int main()
|
|||||||
incomment = 0;
|
incomment = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((c == '(') && spccnt) {
|
if ((c == '(') && (spccnt > 1)) {
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
spccnt = 0;
|
spccnt = 0;
|
||||||
int next = getchar();
|
int next = getchar();
|
||||||
|
Loading…
Reference in New Issue
Block a user