1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 18:48:06 +11:00

Compare commits

..

No commits in common. "a92864a595aaf459402f2c9452a80e0acf89b9d8" and "dabbd6c2530b779acfafc09453da40f7aee23ce7" have entirely different histories.

29 changed files with 70 additions and 91 deletions

View File

@ -9,7 +9,7 @@ Many blocks contain code. That code can be interpreted through
LOAD. Programs stored in blocks frequently have "loader blocks" LOAD. Programs stored in blocks frequently have "loader blocks"
that take care of loading all blocks relevant to the program. that take care of loading all blocks relevant to the program.
Blocks spanning multiple disks are tricky. If your media isn't Blocks spanning multipls disks are tricky. If your media isn't
large enough to hold all Collapse OS blocks in one unit, you'll large enough to hold all Collapse OS blocks in one unit, you'll
have to make it span multiple disks. Block reference in have to make it span multiple disks. Block reference in
informational texts aren't a problem: When you swap your disk, informational texts aren't a problem: When you swap your disk,

View File

@ -7,9 +7,9 @@ modified. "I:" prefix means "IMMEDIATE", that is, that this
stack transformation is made at compile time. stack transformation is made at compile time.
Word references (wordref): When we say we have a "word Word references (wordref): When we say we have a "word
reference", it's a pointer to a word's *code link*. For example, reference", it's a pointer to a word's *code link*. For
the address that "' DUP" puts on the stack is a wordref, that example, the address that "' DUP" is a wordref, that is, a
is, a reference to the code link of the word DUP. reference to the code link of the word DUP.
PF: Parameter field. The area following the code link of a PF: Parameter field. The area following the code link of a
word. For example, "' H@ 1+" points to the PF of the word H@. word. For example, "' H@ 1+" points to the PF of the word H@.

View File

@ -1,6 +1,6 @@
(cont.) (cont.)
0x2b: doesWord. This word is created by "DOES>" and is followed 0x2b: doesWord. This word is created by "DOES>" and is followed
by a 2-byte value as well as the address where "DOES>" was by a 2-byte value as well as the adress where "DOES>" was
compiled. At that address is an atom list exactly like in a compiled. At that address is an atom list exactly like in a
compiled word. Upon execution, after having pushed its cell compiled word. Upon execution, after having pushed its cell
addr to PSP, it execute its reference exactly like a addr to PSP, it execute its reference exactly like a

View File

@ -2,7 +2,7 @@ CREATE ACC 0 ,
: _LIST ." Block " DUP . NL LIST ; : _LIST ." Block " DUP . NL LIST ;
: _NUM : _NUM
ACC @ SWAP _pdacc ACC @ SWAP _pdacc
1 = IF _LIST 0 THEN IF _LIST 0 THEN
ACC ! ACC !
; ;
: L BLK> @ _LIST ; : L BLK> @ _LIST ;

View File

@ -3,7 +3,7 @@ effect described below.
Pressing a 0-9 digit accumulates that digit into what is named Pressing a 0-9 digit accumulates that digit into what is named
the "modifier". That modifier affects the behavior of many the "modifier". That modifier affects the behavior of many
keystrokes described below. The modifier starts at zero, but keystokes described below. The modifier starts at zero, but
most commands interpret a zero as a 1 so that they can have an most commands interpret a zero as a 1 so that they can have an
effect. effect.

View File

@ -1,5 +1,5 @@
On top of that, you have the very nice BREAK, instruction, On top of that, you have the very nice BREAK, instruction,
which must also be preceded by a JRxx, and will jump to the which must also be preceeded by a JRxx, and will jump to the
PC following the next AGAIN, PC following the next AGAIN,

View File

@ -10,7 +10,7 @@ compile it with offsets. We abort on IMMED? because we're
never supposed to encounter an immediate at this point. never supposed to encounter an immediate at this point.
If not found, we try the same word on system dict (RAM+02). If not found, we try the same word on system dict (RAM+02).
If found and is immediate, execute. If found and not immediate, If found and is immediate, execute. If founf and not immediate,
error. If not found, try number. error. If not found, try number.

12
blk/301
View File

@ -1,12 +1,14 @@
L3 BSET PC ORG @ 0x34 + ! ( execute. DE -> wordref ) L3 BSET PC ORG @ 0x34 + ! ( execute )
EXDEHL, ( HL now points to wordref )
( We don't apply BIN( reliably on stable ABI stuff, we ( We don't apply BIN( reliably on stable ABI stuff, we
might need to adjust addr. Ugly, but well... ) might need to adjust addr. Ugly, but well... )
BIN( @ [IF] BIN( @ [IF]
A XORr, D ORr, IFZ, D BIN( @ 256 / LDrn, THEN, A XORr, H ORr, IFZ, H BIN( @ 256 / LDrn, THEN,
[THEN] [THEN]
LDA(DE), E (HL) LDrr,
L A LDrr, D BIN( @ 256 / LDrn,
H BIN( @ 256 / LDrn, EXDEHL,
( HL points to code pointer )
DE INCss, DE INCss,
( DE points to PFA ) ( DE points to PFA )
JP(HL), JP(HL),

View File

@ -2,7 +2,7 @@
( buffer overflow? same as if we typed a newline ) ( buffer overflow? same as if we typed a newline )
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c ) IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr ) DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
( backspace? handle and exit ) ( bacspace? handle and exit )
DUP BS? IF _bs EXIT THEN DUP BS? IF _bs EXIT THEN
( echo back ) ( echo back )
DUP EMIT ( c ) DUP EMIT ( c )

View File

@ -13,4 +13,4 @@ Core words (low) (B350)
Then comes the part where we begin defining words in Forth. Then comes the part where we begin defining words in Forth.
Core words are designed to be cross-compiled (B260), from a Core words are designed to be cross-compiled (B260), from a
full Forth interpreter. This means that it has access to more full Forth interpreter. This means that it has access to more
than boot words. This comes with tricky limitations. (cont.) than boot words. This somes with tricky limitations. (cont.)

View File

@ -6,7 +6,7 @@ to scroll more efficiently. Instead of having to copy the LCD
ram around at each linefeed (or instead of having to maintain ram around at each linefeed (or instead of having to maintain
an in-memory buffer), we can use this feature. an in-memory buffer), we can use this feature.
The Z-Offset goes upwards, with wrapping. For example, if we The Z-Offet goes upwards, with wrapping. For example, if we
have an 8 pixels high line at row 0 and if our offset is 8, have an 8 pixels high line at row 0 and if our offset is 8,
that line will go up 8 pixels, wrapping itself to the bottom of that line will go up 8 pixels, wrapping itself to the bottom of
the screen. the screen.

View File

@ -7,7 +7,7 @@ Start - A - C - B - Right - Left - Down - Up
Each bit is high when button is unpressed and low if button is Each bit is high when button is unpressed and low if button is
pressed. When no button is pressed, 0xff is returned. pressed. When no button is pressed, 0xff is returned.
This logic below is for the Genesis controller, which is modal. This logic below is for the Genesis controller, which is modal.
TH is an output pin that switches the meaning of TL and TR. When TH is an output pin that swiches the meaning of TL and TR. When
TH is high (unselected), TL = Button B and TR = Button C. When TH is high (unselected), TL = Button B and TR = Button C. When
TH is low (selected), TL = Button A and TR = Start. ) TH is low (selected), TL = Button A and TR = Start. )

View File

@ -1 +1 @@
1 9 LOADR+ 1 8 LOADR+

View File

@ -1,7 +1,6 @@
: OP1 CREATE C, DOES> C@ A, ; : OP1 CREATE C, DOES> C@ A, ;
0xc3 OP1 RETn, 0xfa OP1 CLI, 0xfb OP1 STI, 0xc3 OP1 RETn, 0xfa OP1 CLI, 0xfb OP1 STI,
0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD, 0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD,
0x90 OP1 NOP,
( no argument, jumps with relative addrs are special ) ( no argument, jumps with relative addrs are special )
0xeb OP1 JMPs, 0xe9 OP1 JMPn, 0x74 OP1 JZ, 0xeb OP1 JMPs, 0xe9 OP1 JMPn, 0x74 OP1 JZ,
0x75 OP1 JNZ, 0xe8 OP1 CALLn, 0x75 OP1 JNZ, 0xe8 OP1 CALLn,

15
blk/755
View File

@ -1,13 +1,16 @@
: OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR A, ; : OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR A, ;
0x8a OPrm MOVr[], 0x8b OPrm MOVx[], 0x8a OPrm MOVr[], 0x8b OPrm MOVx[],
: OPmr CREATE C, DOES> C@ A, 3 LSHIFT OR A, ;
0x88 OPmr MOV[]r, 0x89 OPmr MOV[]x,
: OPrm+ ( r m off ) CREATE C, DOES> : OPrm+ ( r m off ) CREATE C, DOES>
C@ A, ROT 3 LSHIFT ROT OR 0x40 OR A, A, ; C@ A, ROT 3 LSHIFT ROT OR 0x40 OR A, A, ;
0x8a OPrm+ MOVr[]+, 0x8b OPrm+ MOVx[]+, 0x8a OPrm+ MOVr[]+, 0x8b OPrm+ MOVx[]+,
: OPm+r ( m off r ) CREATE C, DOES> : MOVri, SWAP 0xb0 OR A, A, ;
C@ A, 3 LSHIFT ROT OR 0x40 OR A, A, ; : MOVxI, SWAP 0xb8 OR A, A,, ;
0x88 OPm+r MOV[]+r, 0x89 OPm+r MOV[]+x, : MOVsx, 0x8e A, SWAP 3 LSHIFT OR 0xc0 OR A, ;
: MOVxm, 0x8b A, SWAP 3 LSHIFT 0x6 OR A, A,, ;
: INT, 0xcd A, A, ;
: ADDAXI, 0x05 A, A,, ; : ADDALi, 0x04 A, A, ;
: SUBxi, 0x83 A, SWAP 0xe8 OR A, A, ;
: JMPr, 0xff A, 7 AND 0xe0 OR A, ;
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;

25
blk/756
View File

@ -1,9 +1,16 @@
: MOVri, SWAP 0xb0 OR A, A, ; ( Place BEGIN, where you want to jump back and AGAIN after
: MOVxI, SWAP 0xb8 OR A, A,, ; a relative jump operator. Just like BSET and BWR. )
: MOVsx, 0x8e A, SWAP 3 LSHIFT OR 0xc0 OR A, ; : BEGIN, PC ;
: MOVxm, 0x8b A, SWAP 3 LSHIFT 0x6 OR A, A,, ; : BSET PC SWAP ! ;
: INT, 0xcd A, A, ; ( same as BSET, but we need to write a placeholder )
: ADDAXI, 0x05 A, A,, ; : ADDALi, 0x04 A, A, ; : FJR, PC 0 A, ;
: SUBxi, 0x83 A, SWAP 0xe8 OR A, A, ; : IFZ, JNZ, FJR, ;
: JMPr, 0xff A, 7 AND 0xe0 OR A, ; : IFNZ, JZ, FJR, ;
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ; ( : IFC, JRNC, FJR, ;
: IFNC, JRC, FJR, ; )
: THEN,
DUP PC ( l l pc )
-^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + BIN( @ - ( off addr )
C! ;

26
blk/757
View File

@ -1,16 +1,10 @@
( Place BEGIN, where you want to jump back and AGAIN after : FWRs BSET 0 A, ;
a relative jump operator. Just like BSET and BWR. ) : FSET @ THEN, ;
: BEGIN, PC ; ( : BREAK, FJR, 0x8000 OR ;
: BSET PC SWAP ! ; : BREAK?, DUP 0x8000 AND IF
( same as BSET, but we need to write a placeholder ) 0x7fff AND 1 ALLOT THEN, -1 ALLOT
: FJR, PC 0 A, ; THEN ; )
: IFZ, JNZ, FJR, ; : RPCs, PC - 1- A, ; : RPCn, PC - 2- A,, ;
: IFNZ, JZ, FJR, ; : AGAIN, ( BREAK?, ) RPCs, ;
( : IFC, JRNC, FJR, ; ( Use RPCx with appropriate JMP/CALL op. Example:
: IFNC, JRC, FJR, ; ) JMPs, 0x42 RPCs, or CALLn, 0x1234 RPCn, )
: THEN,
DUP PC ( l l pc )
-^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + BIN( @ - ( off addr )
C! ;

14
blk/758
View File

@ -1,10 +1,4 @@
: FWRs BSET 0 A, ; : CODE ( same as CREATE, but with native word )
: FSET @ THEN, ; (entry)
( : BREAK, FJR, 0x8000 OR ; 23 C, ( 23 == nativeWord ) ;
: BREAK?, DUP 0x8000 AND IF : ;CODE ;
0x7fff AND 1 ALLOT THEN, -1 ALLOT
THEN ; )
: RPCs, PC - 1- A, ; : RPCn, PC - 2- A,, ;
: AGAIN, ( BREAK?, ) RPCs, ;
( Use RPCx with appropriate JMP/CALL op. Example:
JMPs, 0x42 RPCs, or CALLn, 0x1234 RPCn, )

View File

@ -1,4 +0,0 @@
: CODE ( same as CREATE, but with native word )
(entry)
23 C, ( 23 == nativeWord ) ;
: ;CODE JMPn, 0x1a ( next ) RPCn, ;

View File

@ -2,6 +2,4 @@ PC/AT Recipe
Work in progress. Work in progress.
Register usage: SP is PSP, BP is RSP, DX is IP
811 Hello World boot 811 Hello World boot

View File

@ -3,7 +3,7 @@ JMPs, L1 FWRs ( start )
ORG @ 0x25 + HERE ! ( bypass BPB ) ORG @ 0x25 + HERE ! ( bypass BPB )
L1 FSET ( start ) L1 FSET ( start )
CLI, CLD, AX 0x800 MOVxI, DS AX MOVsx, ES AX MOVsx, CLI, CLD, AX 0x800 MOVxI, DS AX MOVsx, ES AX MOVsx,
SS AX MOVsx, STI, SS AX MOVsx, SP 0xffff MOVxI, STI,
AH 2 MOVri, DX 0 MOVxI, CH 0 MOVri, CL 2 MOVri, AL 1 MOVri, AH 2 MOVri, DX 0 MOVxI, CH 0 MOVri, CL 2 MOVri, AL 1 MOVri,
BX 0 MOVxI, 0x13 INT, ( read 2nd sector of boot floppy ) BX 0 MOVxI, 0x13 INT, ( read 2nd sector of boot floppy )
0x800 0 JMPf, 0x800 0 JMPf,

View File

@ -1,3 +1,4 @@
( Registers. SP -> PSP DX -> RSP CX -> IP )
H@ ORG ! H@ ORG !
JMPn, 0 A,, ( 00, main ) JMPn, 0 A,, ( 03, find ) JMPn, 0 A,, ( 00, main ) JMPn, 0 A,, ( 03, find )
0 A,, ( 06, unused ) 0 A,, ( 08, LATEST ) 0 A,, ( 06, unused ) 0 A,, ( 08, LATEST )

View File

@ -6,10 +6,8 @@
4 A, 4 A,
H@ XCURRENT ! ( set current tip of dict, 0x42 ) H@ XCURRENT ! ( set current tip of dict, 0x42 )
0x17 A, ( nativeWord ) 0x17 A, ( nativeWord )
DX [BP] 0 MOVx[]+, BP DECx, BP DECx, ( popRS )
;CODE ;CODE
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
CODE FOO CODE FOO
AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT, AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT,
BEGIN, JMPs, AGAIN,
;CODE ;CODE
: BAR FOO FOO ; : BAZ BAR FOO BYE ;

15
blk/814
View File

@ -1,14 +1,5 @@
PC 0x1d - ORG @ 0x1b + ! ( next ) L1 BSET PC 3 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
DI DX MOVxx, ( <-- IP ) DX INCx, DX INCx, AH AH XORrr,
DI [DI] MOVx[], ( wordref ) AL [DI] MOVr[],
( continue to execute )
L1 BSET PC 0x36 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
AH AH XORrr, AL [DI] MOVr[],
DI INCx, ( PFA ) DI INCx, ( PFA )
AX JMPr, AX JMPr,
PC 0x11 - ORG @ 0x0f + ! ( compiledWord -- DI -> PFA )
BP INCx, BP INCx, [BP] 0 DX MOV[]+x, ( pushRS )
DX DI MOVxx, DX INCx, DX INCx, ( --> IP )
DI [DI] MOVx[],
JMPs, L1 @ RPCs,

View File

@ -1,7 +1,5 @@
L3 BSET 3 A, 'B' A, 'A' A, 'Z' A, L3 BSET 3 A, 'F' A, 'O' A, 'O' A,
PC 3 - ORG @ 1+ ! ( main ) PC 3 - ORG @ 1+ ! ( main )
SP PS_ADDR MOVxI,
BP RS_ADDR MOVxI,
DI 0x08 MOVxm, ( LATEST ) DI 0x08 MOVxm, ( LATEST )
SI L3 @ MOVxI, SI L3 @ MOVxI,
CALLn, L4 @ RPCn, ( find ) CALLn, L4 @ RPCn, ( find )

Binary file not shown.

View File

@ -1,5 +1,3 @@
0xff00 CONSTANT RS_ADDR
0xfffa CONSTANT PS_ADDR
750 LOAD ( 8086 asm ) 750 LOAD ( 8086 asm )
262 LOAD ( xcomp ) 262 LOAD ( xcomp )
270 LOAD ( xcomp overrides ) 270 LOAD ( xcomp overrides )

View File

@ -6,7 +6,7 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
static void usage() void usage()
{ {
fprintf(stderr, "Usage: blkpack dirname\n"); fprintf(stderr, "Usage: blkpack dirname\n");
} }
@ -34,7 +34,7 @@ int main(int argc, char *argv[])
if (blkid >= blkcnt) { if (blkid >= blkcnt) {
int newcnt = blkid+1; int newcnt = blkid+1;
buf = realloc(buf, newcnt*1024); buf = realloc(buf, newcnt*1024);
memset(buf+(blkcnt*1024), 0, (newcnt-blkcnt)*1024); bzero(buf+(blkcnt*1024), (newcnt-blkcnt)*1024);
blkcnt = newcnt; blkcnt = newcnt;
} }
char fullpath[0x200]; char fullpath[0x200];

View File

@ -16,7 +16,7 @@ void mread(int fd, char *s, int count)
} }
} }
static void mexpect(int fd, char ec) void mexpect(int fd, char ec)
{ {
char c; char c;
mread(fd, &c, 1); mread(fd, &c, 1);