1
0
mirror of https://github.com/hsoft/collapseos.git synced 2025-04-02 04:18:39 +11:00

pcat: implement RSP mechanism in execution model

This commit is contained in:
Virgil Dupras 2020-06-16 20:41:53 -04:00
parent 4017fd04ac
commit a92864a595
12 changed files with 56 additions and 43 deletions

View File

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

View File

@ -1,6 +1,7 @@
: 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,16 +1,13 @@
: 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[]+,
: MOVri, SWAP 0xb0 OR A, A, ; : OPm+r ( m off r ) CREATE C, DOES>
: MOVxI, SWAP 0xb8 OR A, A,, ; C@ A, 3 LSHIFT ROT OR 0x40 OR A, A, ;
: MOVsx, 0x8e A, SWAP 3 LSHIFT OR 0xc0 OR A, ; 0x88 OPm+r MOV[]+r, 0x89 OPm+r MOV[]+x,
: 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,16 +1,9 @@
( Place BEGIN, where you want to jump back and AGAIN after : MOVri, SWAP 0xb0 OR A, A, ;
a relative jump operator. Just like BSET and BWR. ) : MOVxI, SWAP 0xb8 OR A, A,, ;
: BEGIN, PC ; : MOVsx, 0x8e A, SWAP 3 LSHIFT OR 0xc0 OR A, ;
: BSET PC SWAP ! ; : MOVxm, 0x8b A, SWAP 3 LSHIFT 0x6 OR A, A,, ;
( same as BSET, but we need to write a placeholder ) : INT, 0xcd A, A, ;
: FJR, PC 0 A, ; : ADDAXI, 0x05 A, A,, ; : ADDALi, 0x04 A, A, ;
: IFZ, JNZ, FJR, ; : SUBxi, 0x83 A, SWAP 0xe8 OR A, A, ;
: IFNZ, JZ, FJR, ; : JMPr, 0xff A, 7 AND 0xe0 OR A, ;
( : IFC, JRNC, FJR, ; : JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;
: 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,10 +1,16 @@
: FWRs BSET 0 A, ; ( Place BEGIN, where you want to jump back and AGAIN after
: FSET @ THEN, ; a relative jump operator. Just like BSET and BWR. )
( : BREAK, FJR, 0x8000 OR ; : BEGIN, PC ;
: BREAK?, DUP 0x8000 AND IF : BSET PC SWAP ! ;
0x7fff AND 1 ALLOT THEN, -1 ALLOT ( same as BSET, but we need to write a placeholder )
THEN ; ) : FJR, PC 0 A, ;
: RPCs, PC - 1- A, ; : RPCn, PC - 2- A,, ; : IFZ, JNZ, FJR, ;
: AGAIN, ( BREAK?, ) RPCs, ; : IFNZ, JZ, FJR, ;
( Use RPCx with appropriate JMP/CALL op. Example: ( : IFC, JRNC, FJR, ;
JMPs, 0x42 RPCs, or CALLn, 0x1234 RPCn, ) : 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
View File

@ -1,4 +1,10 @@
: CODE ( same as CREATE, but with native word ) : FWRs BSET 0 A, ;
(entry) : FSET @ THEN, ;
23 C, ( 23 == nativeWord ) ; ( : BREAK, FJR, 0x8000 OR ;
: ;CODE JMPn, 0x1a ( next ) RPCn, ; : 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
View File

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

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, SP 0xffff MOVxI, STI, SS AX MOVsx, 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

@ -6,9 +6,10 @@
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 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,
;CODE ;CODE
: BAR FOO FOO BYE ; : BAR FOO FOO ; : BAZ BAR FOO BYE ;

View File

@ -8,6 +8,7 @@ L1 BSET PC 0x36 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
AX JMPr, AX JMPr,
PC 0x11 - ORG @ 0x0f + ! ( compiledWord -- DI -> PFA ) 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 ) DX DI MOVxx, DX INCx, DX INCx, ( --> IP )
DI [DI] MOVx[], DI [DI] MOVx[],
JMPs, L1 @ RPCs, JMPs, L1 @ RPCs,

View File

@ -1,5 +1,7 @@
L3 BSET 3 A, 'B' A, 'A' A, 'R' A, L3 BSET 3 A, 'B' A, 'A' A, 'Z' 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 )

View File

@ -1,3 +1,5 @@
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 )