mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-28 08:58:07 +11:00
pcat: add PICK and (roll)
This commit is contained in:
parent
6b07296d30
commit
3b21ba635d
1
blk/751
1
blk/751
@ -8,3 +8,4 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
|
||||
: ES 0 ; : CS 1 ; : SS 2 ; : DS 3 ;
|
||||
: [BX+SI] 0 ; : [BX+DI] 1 ; : [BP+SI] 2 ; : [BP+DI] 3 ;
|
||||
: [SI] 4 ; : [DI] 5 ; : [BP] 6 ; : [BX] 7 ;
|
||||
: <<3 3 LSHIFT ;
|
||||
|
7
blk/753
7
blk/753
@ -2,12 +2,13 @@
|
||||
0xc3 OP1 RETn, 0xfa OP1 CLI, 0xfb OP1 STI,
|
||||
0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD,
|
||||
0x90 OP1 NOP,
|
||||
0xf3 OP1 REPZ, 0xf2 OP1 REPNZ, 0xac OP1 LODSB,
|
||||
0xad OP1 LODSW, 0xa6 OP1 CMPSB, 0xa7 OP1 CMPSW,
|
||||
0xa4 OP1 MOVSB, 0xa5 OP1 MOVSW, 0xae OP1 SCASB,
|
||||
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,
|
||||
0xf3 OP1 REPZ, 0xf2 OP1 REPNZ, 0xac OP1 LODSB,
|
||||
0xa6 OP1 CMPSB, 0xa4 OP1 MOVSB, 0xae OP1 SCASB,
|
||||
0xaa OP1 STOSB,
|
||||
|
||||
: OP1r CREATE C, DOES> C@ + A, ;
|
||||
0x40 OP1r INCx, 0x48 OP1r DECx,
|
||||
|
18
blk/754
18
blk/754
@ -1,16 +1,14 @@
|
||||
: OPrr CREATE C, DOES> C@ A, 3 LSHIFT OR 0xc0 OR A, ;
|
||||
: OPr0 ( reg op ) CREATE C, C, DOES>
|
||||
C@+ A, C@ <<3 OR 0xc0 OR A, ;
|
||||
0 0xd0 OPr0 ROLr1, 0 0xd1 OPr0 ROLx1,
|
||||
1 0xd0 OPr0 RORr1, 1 0xd1 OPr0 RORx1,
|
||||
4 0xd0 OPr0 SHLr1, 4 0xd1 OPr0 SHLx1,
|
||||
5 0xd0 OPr0 SHRr1, 5 0xd1 OPr0 SHRx1,
|
||||
|
||||
: 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,
|
||||
|
||||
: 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]+,
|
||||
|
22
blk/755
22
blk/755
@ -1,14 +1,10 @@
|
||||
: OPrm CREATE C, DOES> C@ A, SWAP 3 LSHIFT OR A, ;
|
||||
0x8a OPrm MOVr[], 0x8b OPrm MOVx[],
|
||||
: 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],
|
||||
|
||||
: 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[]+,
|
||||
0x3a OPrm+ CMPr[]+, 0x3b OPrm+ CMPx[]+,
|
||||
|
||||
: 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,
|
||||
: 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
10
blk/756
@ -1,10 +0,0 @@
|
||||
: 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, ;
|
||||
: ADDxi, 0x83 A, SWAP 0xc0 OR A, A, ;
|
||||
: JMPr, 0xff A, 7 AND 0xe0 OR A, ;
|
||||
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;
|
30
blk/757
30
blk/757
@ -1,16 +1,14 @@
|
||||
( 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! ;
|
||||
: 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[]+,
|
||||
0x3a OPrm+ CMPr[]+, 0x3b OPrm+ CMPx[]+,
|
||||
|
||||
: 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,
|
||||
|
20
blk/758
20
blk/758
@ -1,10 +1,10 @@
|
||||
: 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, )
|
||||
: 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, ;
|
||||
: ADDxi, 0x83 A, SWAP 0xc0 OR A, A, ;
|
||||
: JMPr, 0xff A, 7 AND 0xe0 OR A, ;
|
||||
: JMPf, ( seg off ) 0xea A, SPLITB A, A, A,, ;
|
||||
|
19
blk/759
19
blk/759
@ -1,3 +1,16 @@
|
||||
: CODE ( same as CREATE, but with native word )
|
||||
(entry) 0 ( native ) C, ;
|
||||
: ;CODE JMPn, 0x1a ( next ) 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! ;
|
||||
|
10
blk/760
Normal file
10
blk/760
Normal file
@ -0,0 +1,10 @@
|
||||
: 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, )
|
3
blk/761
Normal file
3
blk/761
Normal file
@ -0,0 +1,3 @@
|
||||
: CODE ( same as CREATE, but with native word )
|
||||
(entry) 0 ( native ) C, ;
|
||||
: ;CODE JMPn, 0x1a ( next ) RPCn, ;
|
14
blk/821
14
blk/821
@ -5,8 +5,12 @@ CODE SWAP AX POPx, BX POPx, AX PUSHx, BX PUSHx, ;CODE
|
||||
CODE OVER ( a b -- a b a )
|
||||
DI SP MOVxx, AX [DI] 2 MOVx[]+, AX PUSHx,
|
||||
;CODE
|
||||
CODE 0 AX AX XORxx, AX PUSHx, ;CODE
|
||||
CODE 1 AX 1 MOVxI, 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 PICK
|
||||
DI POPx, DI SHLx1, ( x2 )
|
||||
DI SP ADDxx, DI [DI] MOVx[], DI PUSHx,
|
||||
;CODE
|
||||
CODE (roll) ( "2 3 4 5 4 --> 2 4 5 5". See B311 )
|
||||
CX POPx, SI SP MOVxx, SI CX ADDxx,
|
||||
DI SI MOVxx, SI DECx, SI DECx,
|
||||
STD, REPZ, MOVSB,
|
||||
;CODE
|
||||
|
11
blk/822
11
blk/822
@ -1,6 +1,5 @@
|
||||
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
|
||||
CODE EMIT
|
||||
AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
|
||||
;CODE
|
||||
: FOO 'A' 'B' 'C' OVER EMIT EMIT EMIT ;
|
||||
: BOOT ['] FOO EXECUTE BYE ;
|
||||
CODE 0 AX AX XORxx, AX PUSHx, ;CODE
|
||||
CODE 1 AX 1 MOVxI, 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
|
||||
|
6
blk/824
Normal file
6
blk/824
Normal file
@ -0,0 +1,6 @@
|
||||
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
|
||||
CODE EMIT
|
||||
AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
|
||||
;CODE
|
||||
: FOO 'A' 'B' 'C' 2 PICK 4 (roll) EMIT EMIT EMIT EMIT ;
|
||||
: BOOT ['] FOO EXECUTE BYE ;
|
@ -3,7 +3,7 @@
|
||||
750 LOAD ( 8086 asm )
|
||||
262 LOAD ( xcomp )
|
||||
270 LOAD ( xcomp overrides )
|
||||
812 822 LOADR
|
||||
812 824 LOADR
|
||||
(entry) _
|
||||
( Update LATEST )
|
||||
PC ORG @ 8 + !
|
||||
|
Loading…
Reference in New Issue
Block a user