mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 10:28:05 +11:00
Compare commits
8 Commits
dabbd6c253
...
a92864a595
Author | SHA1 | Date | |
---|---|---|---|
|
a92864a595 | ||
|
4017fd04ac | ||
|
79da1db90e | ||
|
472331b450 | ||
|
6a09910dfc | ||
|
f1a225ef3d | ||
|
16d6a0b377 | ||
|
feeedcc55c |
2
blk/019
2
blk/019
@ -9,7 +9,7 @@ Many blocks contain code. That code can be interpreted through
|
||||
LOAD. Programs stored in blocks frequently have "loader blocks"
|
||||
that take care of loading all blocks relevant to the program.
|
||||
|
||||
Blocks spanning multipls disks are tricky. If your media isn't
|
||||
Blocks spanning multiple disks are tricky. If your media isn't
|
||||
large enough to hold all Collapse OS blocks in one unit, you'll
|
||||
have to make it span multiple disks. Block reference in
|
||||
informational texts aren't a problem: When you swap your disk,
|
||||
|
6
blk/031
6
blk/031
@ -7,9 +7,9 @@ modified. "I:" prefix means "IMMEDIATE", that is, that this
|
||||
stack transformation is made at compile time.
|
||||
|
||||
Word references (wordref): When we say we have a "word
|
||||
reference", it's a pointer to a word's *code link*. For
|
||||
example, the address that "' DUP" is a wordref, that is, a
|
||||
reference to the code link of the word DUP.
|
||||
reference", it's a pointer to a word's *code link*. For example,
|
||||
the address that "' DUP" puts on the stack is a wordref, that
|
||||
is, a reference to the code link of the word DUP.
|
||||
|
||||
PF: Parameter field. The area following the code link of a
|
||||
word. For example, "' H@ 1+" points to the PF of the word H@.
|
||||
|
2
blk/086
2
blk/086
@ -1,6 +1,6 @@
|
||||
(cont.)
|
||||
0x2b: doesWord. This word is created by "DOES>" and is followed
|
||||
by a 2-byte value as well as the adress where "DOES>" was
|
||||
by a 2-byte value as well as the address where "DOES>" was
|
||||
compiled. At that address is an atom list exactly like in a
|
||||
compiled word. Upon execution, after having pushed its cell
|
||||
addr to PSP, it execute its reference exactly like a
|
||||
|
2
blk/106
2
blk/106
@ -2,7 +2,7 @@ CREATE ACC 0 ,
|
||||
: _LIST ." Block " DUP . NL LIST ;
|
||||
: _NUM
|
||||
ACC @ SWAP _pdacc
|
||||
IF _LIST 0 THEN
|
||||
1 = IF _LIST 0 THEN
|
||||
ACC !
|
||||
;
|
||||
: L BLK> @ _LIST ;
|
||||
|
2
blk/122
2
blk/122
@ -3,7 +3,7 @@ effect described below.
|
||||
|
||||
Pressing a 0-9 digit accumulates that digit into what is named
|
||||
the "modifier". That modifier affects the behavior of many
|
||||
keystokes described below. The modifier starts at zero, but
|
||||
keystrokes described below. The modifier starts at zero, but
|
||||
most commands interpret a zero as a 1 so that they can have an
|
||||
effect.
|
||||
|
||||
|
2
blk/206
2
blk/206
@ -1,5 +1,5 @@
|
||||
On top of that, you have the very nice BREAK, instruction,
|
||||
which must also be preceeded by a JRxx, and will jump to the
|
||||
which must also be preceded by a JRxx, and will jump to the
|
||||
PC following the next AGAIN,
|
||||
|
||||
|
||||
|
2
blk/264
2
blk/264
@ -10,7 +10,7 @@ compile it with offsets. We abort on IMMED? because we're
|
||||
never supposed to encounter an immediate at this point.
|
||||
|
||||
If not found, we try the same word on system dict (RAM+02).
|
||||
If found and is immediate, execute. If founf and not immediate,
|
||||
If found and is immediate, execute. If found and not immediate,
|
||||
error. If not found, try number.
|
||||
|
||||
|
||||
|
12
blk/301
12
blk/301
@ -1,14 +1,12 @@
|
||||
L3 BSET PC ORG @ 0x34 + ! ( execute )
|
||||
EXDEHL, ( HL now points to wordref )
|
||||
L3 BSET PC ORG @ 0x34 + ! ( execute. DE -> wordref )
|
||||
( We don't apply BIN( reliably on stable ABI stuff, we
|
||||
might need to adjust addr. Ugly, but well... )
|
||||
BIN( @ [IF]
|
||||
A XORr, H ORr, IFZ, H BIN( @ 256 / LDrn, THEN,
|
||||
A XORr, D ORr, IFZ, D BIN( @ 256 / LDrn, THEN,
|
||||
[THEN]
|
||||
E (HL) LDrr,
|
||||
D BIN( @ 256 / LDrn,
|
||||
EXDEHL,
|
||||
( HL points to code pointer )
|
||||
LDA(DE),
|
||||
L A LDrr,
|
||||
H BIN( @ 256 / LDrn,
|
||||
DE INCss,
|
||||
( DE points to PFA )
|
||||
JP(HL),
|
||||
|
2
blk/388
2
blk/388
@ -2,7 +2,7 @@
|
||||
( buffer overflow? same as if we typed a newline )
|
||||
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
|
||||
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
|
||||
( bacspace? handle and exit )
|
||||
( backspace? handle and exit )
|
||||
DUP BS? IF _bs EXIT THEN
|
||||
( echo back )
|
||||
DUP EMIT ( c )
|
||||
|
2
blk/422
2
blk/422
@ -13,4 +13,4 @@ Core words (low) (B350)
|
||||
Then comes the part where we begin defining words in Forth.
|
||||
Core words are designed to be cross-compiled (B260), from a
|
||||
full Forth interpreter. This means that it has access to more
|
||||
than boot words. This somes with tricky limitations. (cont.)
|
||||
than boot words. This comes with tricky limitations. (cont.)
|
||||
|
2
blk/552
2
blk/552
@ -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
|
||||
an in-memory buffer), we can use this feature.
|
||||
|
||||
The Z-Offet goes upwards, with wrapping. For example, if we
|
||||
The Z-Offset goes upwards, with wrapping. For example, if we
|
||||
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
|
||||
the screen.
|
||||
|
2
blk/632
2
blk/632
@ -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
|
||||
pressed. When no button is pressed, 0xff is returned.
|
||||
This logic below is for the Genesis controller, which is modal.
|
||||
TH is an output pin that swiches the meaning of TL and TR. When
|
||||
TH is an output pin that switches the meaning of TL and TR. When
|
||||
TH is high (unselected), TL = Button B and TR = Button C. When
|
||||
TH is low (selected), TL = Button A and TR = Start. )
|
||||
|
||||
|
1
blk/753
1
blk/753
@ -1,6 +1,7 @@
|
||||
: OP1 CREATE C, DOES> C@ A, ;
|
||||
0xc3 OP1 RETn, 0xfa OP1 CLI, 0xfb OP1 STI,
|
||||
0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD,
|
||||
0x90 OP1 NOP,
|
||||
( no argument, jumps with relative addrs are special )
|
||||
0xeb OP1 JMPs, 0xe9 OP1 JMPn, 0x74 OP1 JZ,
|
||||
0x75 OP1 JNZ, 0xe8 OP1 CALLn,
|
||||
|
15
blk/755
15
blk/755
@ -1,16 +1,13 @@
|
||||
: OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR A, ;
|
||||
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>
|
||||
C@ A, ROT 3 LSHIFT ROT OR 0x40 OR A, A, ;
|
||||
0x8a OPrm+ MOVr[]+, 0x8b OPrm+ MOVx[]+,
|
||||
|
||||
: MOVri, SWAP 0xb0 OR A, A, ;
|
||||
: MOVxI, SWAP 0xb8 OR A, A,, ;
|
||||
: 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,, ;
|
||||
: OPm+r ( m off r ) CREATE C, DOES>
|
||||
C@ A, 3 LSHIFT ROT OR 0x40 OR A, A, ;
|
||||
0x88 OPm+r MOV[]+r, 0x89 OPm+r MOV[]+x,
|
||||
|
25
blk/756
25
blk/756
@ -1,16 +1,9 @@
|
||||
( Place BEGIN, where you want to jump back and AGAIN after
|
||||
a relative jump operator. Just like BSET and BWR. )
|
||||
: BEGIN, PC ;
|
||||
: BSET PC SWAP ! ;
|
||||
( same as BSET, but we need to write a placeholder )
|
||||
: FJR, PC 0 A, ;
|
||||
: IFZ, JNZ, FJR, ;
|
||||
: IFNZ, JZ, FJR, ;
|
||||
( : 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! ;
|
||||
: MOVri, SWAP 0xb0 OR A, A, ;
|
||||
: MOVxI, SWAP 0xb8 OR A, A,, ;
|
||||
: 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,, ;
|
||||
|
26
blk/757
26
blk/757
@ -1,10 +1,16 @@
|
||||
: FWRs BSET 0 A, ;
|
||||
: FSET @ THEN, ;
|
||||
( : BREAK, FJR, 0x8000 OR ;
|
||||
: BREAK?, DUP 0x8000 AND IF
|
||||
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, )
|
||||
( Place BEGIN, where you want to jump back and AGAIN after
|
||||
a relative jump operator. Just like BSET and BWR. )
|
||||
: BEGIN, PC ;
|
||||
: BSET PC SWAP ! ;
|
||||
( same as BSET, but we need to write a placeholder )
|
||||
: FJR, PC 0 A, ;
|
||||
: IFZ, JNZ, FJR, ;
|
||||
: IFNZ, JZ, FJR, ;
|
||||
( : 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! ;
|
||||
|
14
blk/758
14
blk/758
@ -1,4 +1,10 @@
|
||||
: CODE ( same as CREATE, but with native word )
|
||||
(entry)
|
||||
23 C, ( 23 == nativeWord ) ;
|
||||
: ;CODE ;
|
||||
: FWRs BSET 0 A, ;
|
||||
: FSET @ THEN, ;
|
||||
( : BREAK, FJR, 0x8000 OR ;
|
||||
: BREAK?, DUP 0x8000 AND IF
|
||||
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, )
|
||||
|
4
blk/759
Normal file
4
blk/759
Normal file
@ -0,0 +1,4 @@
|
||||
: CODE ( same as CREATE, but with native word )
|
||||
(entry)
|
||||
23 C, ( 23 == nativeWord ) ;
|
||||
: ;CODE JMPn, 0x1a ( next ) RPCn, ;
|
2
blk/810
2
blk/810
@ -2,4 +2,6 @@ PC/AT Recipe
|
||||
|
||||
Work in progress.
|
||||
|
||||
Register usage: SP is PSP, BP is RSP, DX is IP
|
||||
|
||||
811 Hello World boot
|
||||
|
2
blk/811
2
blk/811
@ -3,7 +3,7 @@ JMPs, L1 FWRs ( start )
|
||||
ORG @ 0x25 + HERE ! ( bypass BPB )
|
||||
L1 FSET ( start )
|
||||
CLI, CLD, AX 0x800 MOVxI, DS AX MOVsx, ES AX MOVsx,
|
||||
SS AX MOVsx, SP 0xffff MOVxI, STI,
|
||||
SS AX MOVsx, STI,
|
||||
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 )
|
||||
0x800 0 JMPf,
|
||||
|
1
blk/812
1
blk/812
@ -1,4 +1,3 @@
|
||||
( Registers. SP -> PSP DX -> RSP CX -> IP )
|
||||
H@ ORG !
|
||||
JMPn, 0 A,, ( 00, main ) JMPn, 0 A,, ( 03, find )
|
||||
0 A,, ( 06, unused ) 0 A,, ( 08, LATEST )
|
||||
|
4
blk/813
4
blk/813
@ -6,8 +6,10 @@
|
||||
4 A,
|
||||
H@ XCURRENT ! ( set current tip of dict, 0x42 )
|
||||
0x17 A, ( nativeWord )
|
||||
DX [BP] 0 MOVx[]+, BP DECx, BP DECx, ( popRS )
|
||||
;CODE
|
||||
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
|
||||
CODE FOO
|
||||
AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT,
|
||||
BEGIN, JMPs, AGAIN,
|
||||
;CODE
|
||||
: BAR FOO FOO ; : BAZ BAR FOO BYE ;
|
||||
|
15
blk/814
15
blk/814
@ -1,5 +1,14 @@
|
||||
L1 BSET PC 3 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
|
||||
AH AH XORrr,
|
||||
AL [DI] MOVr[],
|
||||
PC 0x1d - ORG @ 0x1b + ! ( next )
|
||||
DI DX MOVxx, ( <-- IP ) DX INCx, DX INCx,
|
||||
DI [DI] MOVx[], ( wordref )
|
||||
( continue to execute )
|
||||
L1 BSET PC 0x36 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
|
||||
AH AH XORrr, AL [DI] MOVr[],
|
||||
DI INCx, ( PFA )
|
||||
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,
|
||||
|
4
blk/817
4
blk/817
@ -1,5 +1,7 @@
|
||||
L3 BSET 3 A, 'F' A, 'O' A, 'O' A,
|
||||
L3 BSET 3 A, 'B' A, 'A' A, 'Z' A,
|
||||
PC 3 - ORG @ 1+ ! ( main )
|
||||
SP PS_ADDR MOVxI,
|
||||
BP RS_ADDR MOVxI,
|
||||
DI 0x08 MOVxm, ( LATEST )
|
||||
SI L3 @ MOVxI,
|
||||
CALLn, L4 @ RPCn, ( find )
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
@ -1,3 +1,5 @@
|
||||
0xff00 CONSTANT RS_ADDR
|
||||
0xfffa CONSTANT PS_ADDR
|
||||
750 LOAD ( 8086 asm )
|
||||
262 LOAD ( xcomp )
|
||||
270 LOAD ( xcomp overrides )
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void usage()
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: blkpack dirname\n");
|
||||
}
|
||||
@ -34,7 +34,7 @@ int main(int argc, char *argv[])
|
||||
if (blkid >= blkcnt) {
|
||||
int newcnt = blkid+1;
|
||||
buf = realloc(buf, newcnt*1024);
|
||||
bzero(buf+(blkcnt*1024), (newcnt-blkcnt)*1024);
|
||||
memset(buf+(blkcnt*1024), 0, (newcnt-blkcnt)*1024);
|
||||
blkcnt = newcnt;
|
||||
}
|
||||
char fullpath[0x200];
|
||||
|
@ -16,7 +16,7 @@ void mread(int fd, char *s, int count)
|
||||
}
|
||||
}
|
||||
|
||||
void mexpect(int fd, char ec)
|
||||
static void mexpect(int fd, char ec)
|
||||
{
|
||||
char c;
|
||||
mread(fd, &c, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user