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

Compare commits

..

No commits in common. "faa2576f836359aaf65aace398fb5db67e6e3393" and "b606dbf9af1d9b22565dfde8b1558d6441c5a938" have entirely different histories.

23 changed files with 79 additions and 63 deletions

31
blk/081
View File

@ -1,16 +1,17 @@
RAMSTART FUTURE USES +3c BLK(*
+02 CURRENT +3e FUTURE USES
+04 HERE
+06 C<? +51 CURRENTPTR
+08 C<* override +53 (emit) override
+0a NLPTR +55 (key) override
+0c C<* +57 FUTURE USES
+0e WORDBUF
+2e BOOT C< PTR +5d adev's variables
+30 IN> +5f FUTURE USES
+32 IN(* +70 DRIVERS
+34 BLK@* +80 RAMEND
+36 BLK!*
+38 BLK>
+3a BLKDTY
RAMSTART FUTURE USES +55 (key) override
+02 CURRENT +57 readln's variables
+04 HERE +59 blk's variables
+06 C<? +5b z80a's variables
+08 C<* override +5d adev's variables
+0a NLPTR +5f FUTURE USES
+0c C<* +70 DRIVERS
+0e WORDBUF +80 RAMEND
+2e BOOT C< PTR
+30 FUTURE USES
+4e INTJUMP
+51 CURRENTPTR
+53 (emit) override
(cont.)

View File

@ -9,8 +9,8 @@ PARSEPTR holds routine address called on (parse)
C<* holds routine address called on C<. If the C<* override
at 0x08 is nonzero, this routine is called instead.
IN> is the current position in IN(, which is the input buffer.
IN(* is a pointer to the input buffer, allocated at runtime.
(cont.)

10
blk/083
View File

@ -7,10 +7,10 @@ WORDBUF is the buffer used by WORD
BOOT C< PTR is used when Forth boots from in-memory
source. See "Initialization sequence" below.
INTJUMP All RST offsets (well, not *all* at this moment, I
still have to free those slots...) in boot binaries are made to
jump to this address. If you use one of those slots for an
interrupt, write a jump to the appropriate offset in that RAM
location.
(cont.)

View File

@ -7,9 +7,10 @@ for example), it can point elsewhere.
NLPTR points to an alternative routine for NL (by default,
CRLF).
BLK* see B416.
FUTURE USES section is unused for now.
DRIVERS section is reserved for recipe-specific drivers.
DRIVERS section is reserved for recipe-specific
drivers. Here is a list of known usages:
* 0x70-0x78: ACIA buffer pointers in RC2014 recipes.

View File

@ -1 +1,2 @@
1 37 LOADR+
1 LOAD+ Z80A$
3 37 LOADR+

View File

@ -1,6 +1,9 @@
VARIABLE ORG
VARIABLE BIN( 0 BIN( !
VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: Z80AMEM+ 0x5b RAM+ @ + ;
: ORG 0 Z80AMEM+ ;
: BIN( 2 Z80AMEM+ ;
: L1 4 Z80AMEM+ ; : L2 6 Z80AMEM+ ;
: L3 8 Z80AMEM+ ; : L4 10 Z80AMEM+ ;
: Z80A$ H@ 0x5b RAM+ ! 12 ALLOT 0 BIN( ! ;
: A 7 ; : B 0 ; : C 1 ; : D 2 ;
: E 3 ; : H 4 ; : L 5 ; : (HL) 6 ;
: BC 0 ; : DE 1 ; : HL 2 ; : AF 3 ; : SP AF ;

View File

@ -8,8 +8,8 @@ EXDEHL, JP(HL), NOP, ( 17, nativeWord )
0 JPnn, ( 1a, next ) 0 JPnn, ( 1d, chkPS )
NOP, NOP, ( 20, numberWord ) NOP, NOP, ( 22, litWord )
NOP, NOP, ( 24, addrWord ) NOP, NOP, ( 26, unused )
0 JPnn, ( RST 28 )
RAMSTART 0x4e + JPnn, ( 28, RST 28 )
0 JPnn, ( 2b, doesWord ) NOP, NOP, ( 2e, unused )
0 JPnn, ( RST 30 )
RAMSTART 0x4e + JPnn, ( RST 30 )
0 JPnn, ( 33, execute ) NOP, NOP, ( unused )
0 JPnn, ( RST 38 )
RAMSTART 0x4e + JPnn, ( RST 38 )

11
blk/416
View File

@ -1,12 +1,13 @@
: BLKMEM+ 0x59 RAM+ @ + ;
( n -- Fetches block n and write it to BLK( )
: BLK@* 0x34 RAM+ ;
: BLK@* 0 BLKMEM+ ;
( n -- Write back BLK( to storage at block n )
: BLK!* 0x36 RAM+ ;
: BLK!* 2 BLKMEM+ ;
( Current blk pointer in ( )
: BLK> 0x38 RAM+ ;
: BLK> 4 BLKMEM+ ;
( Whether buffer is dirty )
: BLKDTY 0x3a RAM+ ;
: BLK( 0x3c RAM+ @ ;
: BLKDTY 6 BLKMEM+ ;
: BLK( 8 BLKMEM+ ;
: BLK) BLK( 1024 + ;

View File

@ -1,6 +1,7 @@
: BLK$
H@ 0x3c ( BLK(* ) RAM+ !
1024 ALLOT
H@ 0x59 RAM+ !
( 1024 for the block, 8 for variables )
1032 ALLOT
( LOAD detects end of block with ASCII EOT. This is why
we write it there. EOT == 0x04 )
4 C,

View File

@ -1,9 +1,10 @@
: RDLNMEM+ 0x57 RAM+ @ + ;
( current position in INBUF )
: IN> 0x30 RAM+ ;
: IN> 0 RDLNMEM+ ;
( points to INBUF )
: IN( 0x32 RAM+ @ ;
: IN( 2 RDLNMEM+ ;
( points to INBUF's end )
: IN) 0x40 ( buffer size ) IN( + ;
: IN) 0x40 ( buffer size ) 2+ RDLNMEM+ ;
( flush input buffer )
( set IN> to IN( and set IN> @ to null )

View File

@ -1,9 +1,10 @@
( Initializes the readln subsystem )
: RDLN$
H@ 0x32 ( IN(* ) RAM+ !
( 57 == rdln's memory )
H@ 0x57 RAM+ !
( plus 2 for extra bytes after buffer: 1 for
the last typed 0x0a and one for the following NULL. )
IN) IN( - ALLOT
IN) IN> - 2+ ALLOT
(infl)
['] RDLN< 0x0c RAM+ !
1 0x06 RAM+ ! ( 06 == C<? )

View File

@ -1,4 +1,4 @@
(entry) ~ACIA ( Set RST 38 jump ) PC ORG @ 0x39 + !
CREATE ~ACIA
AF PUSHqq,
HL PUSHqq,
DE PUSHqq,

View File

@ -13,3 +13,5 @@
EI,
RETI,

View File

@ -9,5 +9,8 @@
CR4:2 (101) - 8 bits + 1 stop bit
CR1:0 (10) - Counter divide: 64 )
0b10010110 [ ACIA_CTL LITN ] PC!
( setup interrupt )
0xc3 0x4e RAM+ C! ( c3==JP, 4e==INTJUMP )
~ACIA 0x4f RAM+ !
(im1) ;

View File

@ -1,5 +1,5 @@
0x8000 CONSTANT RAMSTART
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
0xf000 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
0x80 CONSTANT ACIA_CTL 0x81 CONSTANT ACIA_IO
4 CONSTANT SDC_SPI
5 CONSTANT SDC_CSLOW 6 CONSTANT SDC_CSHIGH

View File

@ -53,7 +53,6 @@ Machine* emul_init()
memset(m.mem, 0, 0x10000);
m.ramstart = 0;
m.minsp = 0xffff;
m.maxix = 0;
for (int i=0; i<0x100; i++) {
m.iord[i] = NULL;
m.iowr[i] = NULL;
@ -75,9 +74,6 @@ bool emul_step()
if (newsp != 0 && newsp < m.minsp) {
m.minsp = newsp;
}
if (m.cpu.R1.wr.IX > m.maxix) {
m.maxix = m.cpu.R1.wr.IX;
}
return true;
} else {
return false;
@ -120,5 +116,4 @@ void emul_memdump()
void emul_printdebug()
{
fprintf(stderr, "Min SP: %04x\n", m.minsp);
fprintf(stderr, "Max IX: %04x\n", m.maxix);
}

View File

@ -14,8 +14,6 @@ typedef struct {
ushort ramstart;
// The minimum value reached by SP at any point during execution.
ushort minsp;
// same principle for IX
ushort maxix;
// Array of 0x100 function pointers to IO read and write routines. Leave to
// NULL when IO port is unhandled.
IORD iord[0x100];

Binary file not shown.

View File

@ -20,6 +20,11 @@ trouble of compiling defs to binary.
*/
// When DEBUG is set, stage1 is a core-less forth that works interactively.
// Useful for... debugging!
// By the way: there's a double-echo in stagedbg. It's normal. Don't panic.
//#define DEBUG
#define RAMSTART 0
#define STDIO_PORT 0x00
// To know which part of RAM to dump, we listen to port 2, which at the end of
@ -51,6 +56,10 @@ static uint8_t iord_stdio()
static void iowr_stdio(uint8_t val)
{
// we don't output stdout in stage0
#ifdef DEBUG
// ... unless we're in DEBUG mode!
putchar(val);
#endif
}
static void iowr_here(uint8_t val)
@ -92,11 +101,12 @@ int main(int argc, char *argv[])
while (running && emul_step());
#ifndef DEBUG
// We're done, now let's spit dict data
for (int i=start_here; i<end_here; i++) {
putchar(m->mem[i]);
}
emul_printdebug();
#endif
return 0;
}

View File

@ -1,5 +1,5 @@
0xe800 CONSTANT RAMSTART
0xff00 CONSTANT RS_ADDR
0xf000 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
212 LOAD ( z80 assembler )
262 LOAD ( xcomp )

View File

@ -1,5 +1,5 @@
0x8000 CONSTANT RAMSTART
0xbf00 CONSTANT RS_ADDR
0xb000 CONSTANT RS_ADDR
0xbffa CONSTANT PS_ADDR
RAMSTART 0x70 + CONSTANT LCD_MEM
RAMSTART 0x72 + CONSTANT KBD_MEM

View File

@ -1,4 +1,4 @@
0xff00 CONSTANT RS_ADDR
0xf000 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT RAMSTART
212 LOAD ( z80 assembler )

View File

@ -1,4 +1,4 @@
#!/bin/sh -e
#/bin/sh -e
git submodule init
git submodule update
@ -7,8 +7,6 @@ git clean -fxd
make -C emul
make -C tests
# verify that forth.bin is stable
cp emul/forth.bin ref.bin
make -C emul updatebootstrap
cmp emul/forth.bin ref.bin
rm ref.bin
# let's try again with an updated boot bin
make -C emul updatebootstrap all
make -C tests