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

Compare commits

...

3 Commits

Author SHA1 Message Date
Virgil Dupras
723d3c4249 pcat: all native words implemented!
(well, not PC@ and PC!, but I'm not even sure what would be the role
of these in a PC/AT. they're only used in drivers on the z80 front,
so they will not be immediately needed. todo... )

Now comes the fitting part.
2020-06-19 08:10:51 -04:00
Virgil Dupras
8cc8df0446 pcat: add native _find 2020-06-19 07:56:54 -04:00
Virgil Dupras
5ebdf84e78 pcat: more native words
almost there!
2020-06-19 07:26:33 -04:00
16 changed files with 81 additions and 34 deletions

View File

@ -8,7 +8,8 @@
0xaf OP1 SCASW, 0xaa OP1 STOSB, 0xab OP1 STOSW,
( no argument, jumps with relative addrs are special )
0xeb OP1 JMPs, 0xe9 OP1 JMPn, 0x74 OP1 JZ,
0x75 OP1 JNZ, 0xe8 OP1 CALLn,
0x75 OP1 JNZ, 0x72 OP1 JC, 0x73 OP1 JNC,
0xe8 OP1 CALLn,
: OP1r CREATE C, DOES> C@ + A, ;
0x40 OP1r INCx, 0x48 OP1r DECx,

12
blk/754
View File

@ -4,11 +4,7 @@
1 0xd0 OPr0 RORr1, 1 0xd1 OPr0 RORx1, 4 0xf7 OPr0 MULx,
4 0xd0 OPr0 SHLr1, 4 0xd1 OPr0 SHLx1, 6 0xf6 OPr0 DIVr,
5 0xd0 OPr0 SHRr1, 5 0xd1 OPr0 SHRx1, 6 0xf7 OPr0 DIVx,
: OPrr CREATE C, DOES> C@ A, <<3 OR 0xc0 OR A, ;
0x31 OPrr XORxx, 0x30 OPrr XORrr,
0x88 OPrr MOVrr, 0x89 OPrr MOVxx, 0x28 OPrr SUBrr,
0x29 OPrr SUBxx, 0x08 OPrr ORrr, 0x09 OPrr ORxx,
0x3a OPrr CMPrr, 0x3b OPrr CMPxx, 0x00 OPrr ADDrr,
0x01 OPrr ADDxx, 0x20 OPrr ANDrr, 0x21 OPrr ANDxx,
0 0xd2 OPr0 ROLrCL, 0 0xd3 OPr0 ROLxCL,
1 0xd2 OPr0 RORrCL, 1 0xd3 OPr0 RORxCL,
4 0xd2 OPr0 SHLrCL, 4 0xd3 OPr0 SHLxCL,
5 0xd2 OPr0 SHRrCL, 5 0xd3 OPr0 SHRxCL,

15
blk/755
View File

@ -1,10 +1,7 @@
: OPm ( modrm op ) CREATE C, C, DOES> C@+ A, C@ OR A, ;
0 0xff OPm INC[w], 0 0xfe OPm INC[b],
0x8 0xff OPm DEC[w], 0x8 0xfe OPm DEC[b],
0x30 0xff OPm PUSH[w], 0 0x8f OPm POP[w],
: OPrr CREATE C, DOES> C@ A, <<3 OR 0xc0 OR A, ;
0x31 OPrr XORxx, 0x30 OPrr XORrr,
0x88 OPrr MOVrr, 0x89 OPrr MOVxx, 0x28 OPrr SUBrr,
0x29 OPrr SUBxx, 0x08 OPrr ORrr, 0x09 OPrr ORxx,
0x3a OPrr CMPrr, 0x3b OPrr CMPxx, 0x00 OPrr ADDrr,
0x01 OPrr ADDxx, 0x20 OPrr ANDrr, 0x21 OPrr ANDxx,
: OPm+ ( modrm op ) CREATE C, C, DOES>
( m off ) C@+ A, C@ ROT OR A, A, ;
0x40 0xff OPm+ INC[w]+, 0x40 0xfe OPm+ INC[b]+,
0x48 0xff OPm+ DEC[w]+, 0x48 0xfe OPm+ DEC[b]+,
0x70 0xff OPm+ PUSH[w]+, 0x40 0x8f OPm+ POP[w]+,

10
blk/756 Normal file
View File

@ -0,0 +1,10 @@
: OPm ( modrm op ) CREATE C, C, DOES> C@+ A, C@ OR A, ;
0 0xff OPm INC[w], 0 0xfe OPm INC[b],
0x8 0xff OPm DEC[w], 0x8 0xfe OPm DEC[b],
0x30 0xff OPm PUSH[w], 0 0x8f OPm POP[w],
: OPm+ ( modrm op ) CREATE C, C, DOES>
( m off ) C@+ A, C@ ROT OR A, A, ;
0x40 0xff OPm+ INC[w]+, 0x40 0xfe OPm+ INC[b]+,
0x48 0xff OPm+ DEC[w]+, 0x48 0xfe OPm+ DEC[b]+,
0x70 0xff OPm+ PUSH[w]+, 0x40 0x8f OPm+ POP[w]+,

View File

@ -1,5 +1,6 @@
: OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR A, ;
0x8a OPrm MOVr[], 0x8b OPrm MOVx[],
0x3a OPrm CMPr[], 0x3b OPrm CMPx[],
: OPmr CREATE C, DOES> C@ A, 3 LSHIFT OR A, ;
0x88 OPmr MOV[]r, 0x89 OPmr MOV[]x,

View File

@ -6,8 +6,8 @@
: FJR, PC 0 A, ;
: IFZ, JNZ, FJR, ;
: IFNZ, JZ, FJR, ;
( : IFC, JRNC, FJR, ;
: IFNC, JRC, FJR, ; )
: IFC, JNC, FJR, ;
: IFNC, JC, FJR, ;
: THEN,
DUP PC ( l l pc )
-^ 1- ( l off )

View File

@ -1,3 +1,4 @@
: PUSHZ, CX 0 MOVxI, IFZ, CX INCx, THEN, CX PUSHx, ;
: CODE ( same as CREATE, but with native word )
(entry) 0 ( native ) C, ;
: ;CODE JMPn, 0x1a ( next ) RPCn, ;

View File

@ -4,7 +4,7 @@ ORG @ 0x25 + HERE ! ( bypass BPB )
L1 FSET ( start )
CLI, CLD, AX 0x800 MOVxI, DS AX MOVsx, ES AX MOVsx,
SS AX MOVsx, STI,
AH 2 MOVri, DX 0 MOVxI, CH 0 MOVri, CL 2 MOVri, AL 2 MOVri,
BX 0 MOVxI, 0x13 INT, ( read sectors 2-3 of boot floppy )
AH 2 MOVri, DX 0 MOVxI, CH 0 MOVri, CL 2 MOVri, AL 3 MOVri,
BX 0 MOVxI, 0x13 INT, ( read sectors 2-4 of boot floppy )
0x800 0 JMPf,
ORG @ 0x1fe + HERE ! 0x55 A, 0xaa A,

View File

@ -1,4 +1,4 @@
VARIABLE lblexec VARIABLE lblfind
VARIABLE lblexec VARIABLE lblfind VARIABLE lblnext
H@ ORG !
JMPn, 0 A,, ( 00, main ) 0 A, 0 A,, ( unused )
0 A,, ( unused ) 0 A,, ( 08, LATEST )

View File

@ -1,4 +1,4 @@
PC 0x1d - ORG @ 0x1b + ! ( next )
lblnext BSET PC 0x1d - ORG @ 0x1b + ! ( next )
DI DX MOVxx, ( <-- IP ) DX INCx, DX INCx,
DI [DI] MOVx[], ( wordref )
( continue to execute )

18
blk/824
View File

@ -1,11 +1,11 @@
CODE 0 AX AX XORxx, AX PUSHx, ;CODE
CODE 1 AX 1 MOVxI, AX PUSHx, ;CODE
CODE ! DI POPx, AX POPx, [DI] AX MOV[]x, ;CODE
CODE @ DI POPx, AX [DI] MOVx[], AX PUSHx, ;CODE
CODE C! DI POPx, AX POPx, [DI] AX MOV[]r, ;CODE
CODE C@
DI POPx, AH AH XORrr, AL [DI] MOVr[], AX PUSHx, ;CODE
CODE I [BP] 0 PUSH[w]+, ;CODE
CODE 1+ DI SP MOVxx, [DI] INC[w], ;CODE
CODE 1- DI SP MOVxx, [DI] DEC[w], ;CODE
CODE I' [BP] -2 PUSH[w]+, ;CODE
CODE J [BP] -4 PUSH[w]+, ;CODE
CODE (resSP) SP PS_ADDR MOVxI, ;CODE
CODE (resRS) BP RS_ADDR MOVxI, ;CODE
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
CODE EMIT
AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
;CODE
: FOO 42 10 /MOD '0' + EMIT '0' + EMIT ;
: BOOT ['] FOO EXECUTE BYE ;

15
blk/825 Normal file
View File

@ -0,0 +1,15 @@
CODE S=
SI POPx, DI POPx, CH CH XORrr, CL [SI] MOVr[],
CL [DI] CMPr[],
IFZ, ( same size? )
SI INCx, DI INCx, CLD, REPZ, CMPSB,
THEN,
PUSHZ,
;CODE
CODE CMP
BX POPx, AX POPx, CX CX XORxx, AX BX CMPxx,
IFNZ, ( < or > )
CX INCx, IFNC, ( < ) CX DECx, CX DECx, THEN,
THEN,
CX PUSHx,
;CODE

9
blk/826 Normal file
View File

@ -0,0 +1,9 @@
CODE _find ( cur w -- a f )
SI POPx, ( w ) DI POPx, ( cur )
CALLn, lblfind @ RPCn,
IFNZ, ( not found )
SI PUSHx, AX AX XORxx, AX PUSHx,
JMPn, lblnext @ RPCn,
THEN, ( found )
DI PUSHx, AX 1 MOVxI, AX PUSHx,
;CODE

11
blk/827 Normal file
View File

@ -0,0 +1,11 @@
CODE 0 AX AX XORxx, AX PUSHx, ;CODE
CODE 1 AX 1 MOVxI, AX PUSHx, ;CODE
CODE -1 AX -1 MOVxI, AX PUSHx, ;CODE
CODE 1+ DI SP MOVxx, [DI] INC[w], ;CODE
CODE 1- DI SP MOVxx, [DI] DEC[w], ;CODE
CODE 2+ DI SP MOVxx, [DI] INC[w], [DI] INC[w], ;CODE
CODE 2- DI SP MOVxx, [DI] DEC[w], [DI] DEC[w], ;CODE
CODE RSHIFT ( n u -- n )
CX POPx, AX POPx, AX SHRxCL, AX PUSHx, ;CODE
CODE LSHIFT ( n u -- n )
CX POPx, AX POPx, AX SHLxCL, AX PUSHx, ;CODE

6
blk/828 Normal file
View File

@ -0,0 +1,6 @@
CODE EMIT
AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
;CODE
: FOO '0' 1 3 LSHIFT + EMIT ;
L1 BSET 3 A, 'F' A, 'O' A, 'O' A,
: BOOT 0x08 @ [ L1 @ LITN ] _find DROP EXECUTE BYE ;

View File

@ -3,7 +3,7 @@
750 LOAD ( 8086 asm )
262 LOAD ( xcomp )
270 LOAD ( xcomp overrides )
812 824 LOADR
812 828 LOADR
(entry) _
( Update LATEST )
PC ORG @ 8 + !