1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 19:58:06 +11:00

pcat: more native words

This commit is contained in:
Virgil Dupras 2020-06-18 23:10:14 -04:00
parent 3b21ba635d
commit 89bc7df120
4 changed files with 38 additions and 11 deletions

10
blk/754
View File

@ -1,14 +1,14 @@
: 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,
0 0xd0 OPr0 ROLr1, 0 0xd1 OPr0 ROLx1, 4 0xf6 OPr0 MULr,
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,
0x01 OPrr ADDxx, 0x20 OPrr ANDrr, 0x21 OPrr ANDxx,

19
blk/822
View File

@ -1,5 +1,14 @@
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 2DROP SP 4 ADDxi, ;CODE
CODE 2DUP
AX POPx, BX POPx,
BX PUSHx, AX PUSHx, BX PUSHx, AX PUSHx,
;CODE
CODE S0 AX PS_ADDR MOVxI, AX PUSHx, ;CODE
CODE 'S SP PUSHx, ;CODE
CODE AND AX POPx, BX POPx, AX BX ANDxx, AX PUSHx, ;CODE
CODE OR AX POPx, BX POPx, AX BX ORxx, AX PUSHx, ;CODE
CODE XOR AX POPx, BX POPx, AX BX XORxx, AX PUSHx, ;CODE
CODE NOT
AX POPx, AX AX ORxx,
IFNZ, AX -1 MOVxI, THEN, AX INCx, AX PUSHx,
;CODE

13
blk/823 Normal file
View File

@ -0,0 +1,13 @@
CODE + AX POPx, BX POPx, AX BX ADDxx, AX PUSHx, ;CODE
CODE - BX POPx, AX POPx, AX BX SUBxx, AX PUSHx, ;CODE
CODE *
AX POPx, BX POPx,
DX PUSHx, ( protect from MUL ) BX MULx, DX POPx,
AX PUSHx,
;CODE
CODE /MOD
BX POPx, AX POPx,
BL DIVr, ( TODO: use DIVx, risk of 8086 error )
BH BH XORrr, BL AH MOVrr, BX PUSHx, ( modulo )
BL AL MOVrr, BX PUSHx, ( division )
;CODE

View File

@ -1,6 +1,11 @@
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 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 ;
: FOO 42 10 /MOD '0' + EMIT '0' + EMIT ;
: BOOT ['] FOO EXECUTE BYE ;