mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:18:06 +11:00
pcat: begin implementing find
Not comparing strings yet. Without asm tooling support, it's a big chunk to swallow at once. It's progressing well!
This commit is contained in:
parent
3be30e24bb
commit
8c452f5add
12
blk/753
12
blk/753
@ -1,9 +1,13 @@
|
||||
: OP1 CREATE C, DOES> C@ A, ;
|
||||
0xac OP1 LODSB, 0xfa OP1 CLI, 0xfb OP1 STI,
|
||||
0xc3 OP1 RETn, 0xfa OP1 CLI, 0xfb OP1 STI,
|
||||
0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD,
|
||||
( no argument, jumps with relative addrs are special )
|
||||
0xeb OP1 JMPs, 0xe9 OP1 JMPn, 0x74 OP1 JZ,
|
||||
0xe8 OP1 CALLn,
|
||||
0x75 OP1 JNZ, 0xe8 OP1 CALLn,
|
||||
0xf3 OP1 REPZ, 0xf2 OP1 REPNZ, 0xac OP1 LODSB,
|
||||
0xa6 OP1 CMPSB, 0xa4 OP1 MOVSB, 0xae OP1 SCASB,
|
||||
0xaa OP1 STOSB,
|
||||
|
||||
: OPrr CREATE C, DOES> C@ A, 3 LSHIFT OR 0xc0 OR A, ;
|
||||
0x31 OPrr XORxx, 0x30 OPrr XORrr, 0x08 OPrr ORrr,
|
||||
: OP1r CREATE C, DOES> C@ + A, ;
|
||||
0x40 OP1r INCx, 0x48 OP1r DECx,
|
||||
0x58 OP1r POPx, 0x50 OP1r PUSHx,
|
||||
|
14
blk/754
14
blk/754
@ -1,9 +1,5 @@
|
||||
: 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,, ;
|
||||
: MOVr[], 0x8a A, SWAP 3 LSHIFT OR A, ;
|
||||
: INCx, 0x40 OR A, ;
|
||||
: INT, 0xcd A, A, ;
|
||||
: JMPr, 0xff A, 7 AND 0xe0 OR A, ;
|
||||
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;
|
||||
: OPrr CREATE C, DOES> C@ A, 3 LSHIFT 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,
|
||||
|
27
blk/755
27
blk/755
@ -1,16 +1,11 @@
|
||||
( 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, JRNZ, FJR, ;
|
||||
: IFNZ, JRZ, 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! ;
|
||||
: OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR 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, ;
|
||||
: JMPr, 0xff A, 7 AND 0xe0 OR A, ;
|
||||
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;
|
||||
|
26
blk/756
26
blk/756
@ -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/757
14
blk/757
@ -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/758
Normal file
4
blk/758
Normal file
@ -0,0 +1,4 @@
|
||||
: CODE ( same as CREATE, but with native word )
|
||||
(entry)
|
||||
23 C, ( 23 == nativeWord ) ;
|
||||
: ;CODE ;
|
2
blk/813
2
blk/813
@ -8,8 +8,6 @@ H@ XCURRENT ! ( set current tip of dict, 0x42 )
|
||||
0x17 A, ( nativeWord )
|
||||
;CODE
|
||||
CODE FOO
|
||||
( Update LATEST, temporarily hackish )
|
||||
PC 1- ORG @ 8 + !
|
||||
AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT,
|
||||
L2 BSET JMPs, L2 @ RPCs,
|
||||
;CODE
|
||||
|
3
blk/814
3
blk/814
@ -3,6 +3,3 @@ L1 BSET PC 3 - ORG @ 0x34 + ! ( execute -- BX -> wordref )
|
||||
AL [BX] MOVr[],
|
||||
BX INCx, ( PFA )
|
||||
AX JMPr,
|
||||
|
||||
PC 3 - ORG @ 1+ ! ( main )
|
||||
BX 0x08 MOVxm, ( LATEST ) JMPs, L1 @ RPCs, ( execute )
|
||||
|
14
blk/815
Normal file
14
blk/815
Normal file
@ -0,0 +1,14 @@
|
||||
L4 BSET PC 3 - ORG @ 4 + ! ( find )
|
||||
( find word the same name as str in SI starting from tip in
|
||||
BX. Returns wordref in BX. Z if found, NZ if not. )
|
||||
CH CH XORrr, CL [SI] MOVr[], ( CX -> strlen )
|
||||
SI INCx,
|
||||
AX AX XORxx, ( initial prev )
|
||||
BEGIN, ( inner )
|
||||
BX AX SUBxx, ( jump to prev wordref )
|
||||
BX DECx, AL [BX] MOVr[], ( strlen )
|
||||
CL AL CMPrr, IFZ, BX INCx, RETn, THEN,
|
||||
BX DECx, BX DECx, AX [BX] MOVx[], ( prev )
|
||||
AX AX ORxx,
|
||||
JNZ, AGAIN,
|
||||
BEGIN, JMPs, AGAIN,
|
6
blk/816
Normal file
6
blk/816
Normal file
@ -0,0 +1,6 @@
|
||||
L3 BSET 3 A, 'F' A, 'O' A, 'O' A,
|
||||
PC 3 - ORG @ 1+ ! ( main )
|
||||
BX 0x08 MOVxm, ( LATEST )
|
||||
SI L3 @ MOVxi,
|
||||
CALLn, L4 @ RPCn, ( find )
|
||||
JMPs, L1 @ RPCs, ( execute )
|
@ -1,6 +1,9 @@
|
||||
750 LOAD ( 8086 asm )
|
||||
262 LOAD ( xcomp )
|
||||
270 LOAD ( xcomp overrides )
|
||||
812 814 LOADR
|
||||
812 816 LOADR
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
ORG @ 256 /MOD 2 PC! 2 PC!
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
Loading…
Reference in New Issue
Block a user