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

Compare commits

...

2 Commits

Author SHA1 Message Date
Virgil Dupras
bc8144b4be pcat: implement (br) and (br?) 2020-06-16 22:10:32 -04:00
Virgil Dupras
49979404a5 pcat: implement number literals 2020-06-16 21:34:35 -04:00
9 changed files with 71 additions and 59 deletions

View File

@ -1,7 +1,7 @@
CODE (?br) ( 0x67 ) CODE (?br) ( 0x67 )
HL POPqq, HL POPqq,
HLZ, HLZ,
JRZ, L2 BWR ( BR + 2. False, branch ) JRZ, L2 BWR ( br + 1. False, branch )
L1 BSET ( loop will jump here ) L1 BSET ( loop will jump here )
( True, skip next 2 bytes and don't branch ) ( True, skip next 2 bytes and don't branch )
IY INCss, IY INCss, IY INCss, IY INCss,

View File

@ -2,4 +2,5 @@
0x31 OPrr XORxx, 0x30 OPrr XORrr, 0x31 OPrr XORxx, 0x30 OPrr XORrr,
0x88 OPrr MOVrr, 0x89 OPrr MOVxx, 0x28 OPrr SUBrr, 0x88 OPrr MOVrr, 0x89 OPrr MOVxx, 0x28 OPrr SUBrr,
0x29 OPrr SUBxx, 0x08 OPrr ORrr, 0x09 OPrr ORxx, 0x29 OPrr SUBxx, 0x08 OPrr ORrr, 0x09 OPrr ORxx,
0x3a OPrr CMPrr, 0x3b OPrr CMPxx, 0x3a OPrr CMPrr, 0x3b OPrr CMPxx, 0x00 OPrr ADDrr,
0x01 OPrr ADDxx,

21
blk/813
View File

@ -1,15 +1,16 @@
( BOOT DICT: There are only 3 words in the boot dict, but ( BOOT DICT: There are only 3 words in the boot dict, but
these words' offset need to be stable, so they're part of these words' offset need to be stable, so they're part of
the "stable ABI" ) the "stable ABI" )
'E' A, 'X' A, 'I' A, 'T' A, 'E' A, 'X' A, 'I' A, 'T' A, 0 A,, ( prev ) 4 A, ( len )
0 A,, ( prev ) H@ XCURRENT ! ( set current tip of dict, 0x42 )
4 A, 0x17 A, ( nativeWord )
H@ XCURRENT ! ( set current tip of dict, 0x42 )
0x17 A, ( nativeWord )
DX [BP] 0 MOVx[]+, BP DECx, BP DECx, ( popRS ) DX [BP] 0 MOVx[]+, BP DECx, BP DECx, ( popRS )
;CODE NOP,
CODE (br) ( 0x53 ) L2 BSET ( used in br? )
DI DX MOVxx, DI [DI] MOVx[], DX DI ADDxx,
;CODE NOP, NOP,
CODE (br?) ( 0x67 )
AX POPx, AX AX ORxx, JZ, L2 @ RPCs, ( False, branch )
( True, skip next 2 bytes and don't branch )
DX INCx, DX INCx,
;CODE ;CODE
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
CODE FOO
AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT,
;CODE
: BAR FOO FOO ; : BAZ BAR FOO BYE ;

19
blk/814
View File

@ -1,14 +1,5 @@
PC 0x1d - ORG @ 0x1b + ! ( next ) PC ORG @ 0x20 + ! ( numberWord )
DI DX MOVxx, ( <-- IP ) DX INCx, DX INCx, PC ORG @ 0x24 + ! ( addrWord ) ( see B287 for comments )
DI [DI] MOVx[], ( wordref ) DI DX MOVxx, DI [DI] MOVx[], DI PUSHx,
( continue to execute ) DX INCx, DX INCx,
L1 BSET PC 0x36 - ORG @ 0x34 + ! ( execute -- DI -> wordref ) ;CODE
AH AH XORrr, AL [DI] MOVr[],
DI INCx, ( PFA )
AX JMPr,
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 )
DI [DI] MOVx[],
JMPs, L1 @ RPCs,

30
blk/815
View File

@ -1,16 +1,14 @@
L4 BSET PC 3 - ORG @ 4 + ! ( find ) PC 0x1d - ORG @ 0x1b + ! ( next )
( find word the same name as str in SI starting from tip in DI DX MOVxx, ( <-- IP ) DX INCx, DX INCx,
DI. Returns wordref in BX. Z if found, NZ if not. ) DI [DI] MOVx[], ( wordref )
CH CH XORrr, CL [SI] MOVr[], ( CX -> strlen ) ( continue to execute )
SI INCx, ( first char ) AX AX XORxx, ( initial prev ) L1 BSET PC 0x36 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
BEGIN, ( loop ) AH AH XORrr, AL [DI] MOVr[],
DI AX SUBxx, ( jump to prev wordref ) DI INCx, ( PFA )
AL [DI] -1 MOVr[]+, ( strlen ) AX JMPr,
CL AL CMPrr, IFZ, ( same len )
SI PUSHx, DI PUSHx, CX PUSHx, ( --> lvl 3 ) PC 0x11 - ORG @ 0x0f + ! ( compiledWord -- DI -> PFA )
3 ADDALi, ( header ) AH AH XORrr, DI AX SUBxx, BP INCx, BP INCx, [BP] 0 DX MOV[]+x, ( pushRS )
REPZ, CMPSB, DX DI MOVxx, DX INCx, DX INCx, ( --> IP )
CX POPx, DI POPx, SI POPx, ( <-- lvl 3 ) DI [DI] MOVx[],
IFZ, AL AL XORrr, ( Z ) RETn, THEN, JMPs, L1 @ RPCs,
THEN,
( cont. )

22
blk/816
View File

@ -1,6 +1,16 @@
( find cont. ) L4 BSET PC 3 - ORG @ 4 + ! ( find )
DI 3 SUBxi, AX [DI] MOVx[], ( prev ) ( find word the same name as str in SI starting from tip in
AX AX ORxx, DI. Returns wordref in DI. Z if found, NZ if not. )
JNZ, AGAIN, ( loop ) CH CH XORrr, CL [SI] MOVr[], ( CX -> strlen )
AX INCx, ( NZ ) RETn, SI INCx, ( first char ) AX AX XORxx, ( initial prev )
BEGIN, ( loop )
DI AX SUBxx, ( jump to prev wordref )
AL [DI] -1 MOVr[]+, ( strlen )
CL AL CMPrr, IFZ, ( same len )
SI PUSHx, DI PUSHx, CX PUSHx, ( --> lvl 3 )
3 ADDALi, ( header ) AH AH XORrr, DI AX SUBxx,
REPZ, CMPSB,
CX POPx, DI POPx, SI POPx, ( <-- lvl 3 )
IFZ, AL AL XORrr, ( Z ) RETn, THEN,
THEN,
( cont. )

16
blk/817
View File

@ -1,10 +1,6 @@
L3 BSET 3 A, 'B' A, 'A' A, 'Z' A, ( find cont. )
PC 3 - ORG @ 1+ ! ( main ) DI 3 SUBxi, AX [DI] MOVx[], ( prev )
SP PS_ADDR MOVxI, AX AX ORxx,
BP RS_ADDR MOVxI, JNZ, AGAIN, ( loop )
DI 0x08 MOVxm, ( LATEST ) AX INCx, ( NZ ) RETn,
SI L3 @ MOVxI,
CALLn, L4 @ RPCn, ( find )
IFZ, JMPs, L1 @ RPCs, ( execute ) THEN,
AH 0x0e MOVri, ( print char ) AL '!' MOVri, 0x10 INT,
BEGIN, JMPs, AGAIN,

15
blk/818 Normal file
View File

@ -0,0 +1,15 @@
CODE BYE BEGIN, JMPs, AGAIN, ;CODE
CODE EMIT
AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
;CODE CODE 0 AX AX XORxx, AX PUSHx, ;CODE
: FOO 'X' EMIT ; : BAR 0 IF FOO THEN FOO BYE ;
L3 BSET 3 A, 'B' A, 'A' A, 'R' A,
PC 3 - ORG @ 1+ ! ( main )
SP PS_ADDR MOVxI,
BP RS_ADDR MOVxI,
DI 0x08 MOVxm, ( LATEST )
SI L3 @ MOVxI,
CALLn, L4 @ RPCn, ( find )
IFZ, JMPn, L1 @ RPCn, ( execute ) THEN,
AH 0x0e MOVri, ( print char ) AL '!' MOVri, 0x10 INT,
BEGIN, JMPs, AGAIN,

View File

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