mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:28:06 +11:00
Extract (br), (?br) and (loop)'s code out of stable ABI zone
There is now no more actual code in stable ABI, only references. This makes refactoring of this code much easier. For example, changing IY to BC as the IP register.
This commit is contained in:
parent
daeb3b3c69
commit
f2f520cacc
16
blk/283
16
blk/283
@ -1,14 +1,12 @@
|
||||
H@ ORG !
|
||||
H@ ORG ! ( STABLE ABI )
|
||||
0 JP, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT )
|
||||
NOP, NOP, ( 06, uflw ) NOP, NOP, ( 08, LATEST ) NOP, ( unused )
|
||||
0 A, 0 JP, ( 0b, EXIT ) NOP, ( unused )
|
||||
0 JP, ( RST 10 ) NOP, NOP, NOP, NOP, ( unused )
|
||||
NOP, NOP, NOP, ( unused )
|
||||
0 JP, ( RST 10 ) NOP, NOP, NOP, NOP, NOP, NOP, NOP, ( unused )
|
||||
0 JP, ( 1a, next ) NOP, NOP, NOP, ( unused )
|
||||
0 JP, ( RST 20 )
|
||||
0 A, 0 JP, ( 23, (n) ) NOP, ( unused )
|
||||
0 JP, ( RST 28 )
|
||||
0 A, 0 JP, ( 2b, (s) ) NOP, ( unused )
|
||||
0 JP, ( RST 30 )
|
||||
0 A, 0 JP, ( 33, 2>R ) NOP, ( unused )
|
||||
0 JP, ( RST 20 ) 0 A, 0 JP, ( 23, (n) ) NOP, ( unused )
|
||||
0 JP, ( RST 28 ) 0 A, 0 JP, ( 2b, (s) ) NOP, ( unused )
|
||||
0 JP, ( RST 30 ) 0 A, 0 JP, ( 33, 2>R ) NOP, ( unused )
|
||||
0 JP, ( RST 38 )
|
||||
0 A, 0 JP, ( 3b, (br) ) 0 A, 0 JP, ( 3f, (?br) )
|
||||
0 A, 0 JP, ( 43, (loop) )
|
||||
|
16
blk/284
16
blk/284
@ -1,7 +1,15 @@
|
||||
ORG @ 0x4c + HERE !
|
||||
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
|
||||
CODE (br) ( 0x53 )
|
||||
L2 BSET ( used in CBR )
|
||||
CODE (br) ( TODO: move with other native words )
|
||||
L1 BSET ( used in ?br and loop )
|
||||
PC ORG @ 0x3d + ! ( stable ABI JP )
|
||||
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
|
||||
DE ADDIYd,
|
||||
JPNEXT,
|
||||
;CODE
|
||||
CODE (?br)
|
||||
PC ORG @ 0x41 + ! ( stable ABI JP )
|
||||
HL POP,
|
||||
HLZ,
|
||||
JRZ, L1 BWR ( br + 1. False, branch )
|
||||
( True, skip next 2 bytes and don't branch )
|
||||
IY INCd, IY INCd,
|
||||
;CODE
|
||||
|
20
blk/285
20
blk/285
@ -1,16 +1,10 @@
|
||||
CODE (?br) ( 0x67 )
|
||||
HL POP,
|
||||
HLZ,
|
||||
JRZ, L2 BWR ( br + 1. False, branch )
|
||||
L1 BSET ( loop will jump here )
|
||||
( True, skip next 2 bytes and don't branch )
|
||||
IY INCd, IY INCd,
|
||||
JPNEXT, NOP, NOP, NOP,
|
||||
CODE (loop) ( 0x80 )
|
||||
CODE (loop)
|
||||
PC ORG @ 0x45 + ! ( stable ABI JP )
|
||||
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
|
||||
( Jump if I <> I' )
|
||||
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
|
||||
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
|
||||
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
|
||||
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
|
||||
( don't branch )
|
||||
IX DECd, IX DECd, IX DECd, IX DECd, JR, L1 BWR
|
||||
( END OF STABLE ABI )
|
||||
IX DECd, IX DECd, IX DECd, IX DECd,
|
||||
IY INCd, IY INCd,
|
||||
;CODE
|
||||
|
2
blk/397
2
blk/397
@ -1,7 +1,7 @@
|
||||
( Now we have "as late as possible" stuff. See B70 and B260. )
|
||||
: _bchk DUP 0x7f + 0xff > IF LIT< br-ovfl (print) ABORT THEN ;
|
||||
: DO 0x33 ( 2>R ) , H@ ; IMMEDIATE
|
||||
: LOOP 0x80 ( loop ) , H@ - _bchk , ; IMMEDIATE
|
||||
: LOOP 0x43 ( loop ) , H@ - _bchk , ; IMMEDIATE
|
||||
( LEAVE is implemented in low xcomp )
|
||||
: LITN 0x23 ( n ) , , ;
|
||||
( gets its name at the very end. can't comment afterwards )
|
||||
|
4
blk/398
4
blk/398
@ -1,11 +1,11 @@
|
||||
: IF ( -- a | a: br cell addr )
|
||||
0x67 ( ?br ) , H@ 2 ALLOT ( br cell allot )
|
||||
0x3f ( ?br ) , H@ 2 ALLOT ( br cell allot )
|
||||
; IMMEDIATE
|
||||
: THEN ( a -- | a: br cell addr )
|
||||
DUP H@ -^ _bchk SWAP ( a-H a ) !
|
||||
; IMMEDIATE
|
||||
: ELSE ( a1 -- a2 | a1: IF cell a2: ELSE cell )
|
||||
0x53 ( br ) ,
|
||||
0x3b ( br ) ,
|
||||
2 ALLOT
|
||||
[COMPILE] THEN
|
||||
H@ 2- ( push a. -2 for allot offset )
|
||||
|
4
blk/399
4
blk/399
@ -1,7 +1,7 @@
|
||||
: LIT< 0x2b ( s ) , WORD DUP C@ 1+ MOVE, ; IMMEDIATE
|
||||
: BEGIN H@ ; IMMEDIATE
|
||||
: AGAIN 0x53 ( br ) , H@ - _bchk , ; IMMEDIATE
|
||||
: UNTIL 0x67 ( ?br ) , H@ - _bchk , ; IMMEDIATE
|
||||
: AGAIN 0x3b ( br ) , H@ - _bchk , ; IMMEDIATE
|
||||
: UNTIL 0x3f ( ?br ) , H@ - _bchk , ; IMMEDIATE
|
||||
: [ INTERPRET ; IMMEDIATE
|
||||
: ] R> DROP ;
|
||||
: COMPILE ' LITN ['] , , ; IMMEDIATE
|
||||
|
2
blk/805
2
blk/805
@ -12,3 +12,5 @@ JMPn, 0 A,, ( 1a, next ) 0 A,, 0 A,, 0 A,, ( unused )
|
||||
0 A, JMPn, 0 A,, ( 2b, (s) ) 0 A, ( unused )
|
||||
0 A, 0 A,, ( unused )
|
||||
0 A, JMPn, 0 A,, ( 33, 2>R ) 0 A, 0 A, 0 A,, ( unused )
|
||||
0 A, JMPn, 0 A,, ( 3b, (br) ) 0 A, JMPn, 0 A,, ( 3f, (?br) )
|
||||
0 A, JMPn, 0 A,, ( 43, (loop) )
|
||||
|
16
blk/806
16
blk/806
@ -1,10 +1,12 @@
|
||||
ORG @ 0x4c + HERE !
|
||||
( TODO: move these words with other native words. )
|
||||
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
|
||||
CODE (br) ( 0x53 ) L2 BSET ( used in br? )
|
||||
CODE (br) L1 BSET ( used in ?br )
|
||||
PC 0x3f - ORG @ 0x3d + ! ( stable abi )
|
||||
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 )
|
||||
;CODE
|
||||
CODE (?br)
|
||||
PC 0x43 - ORG @ 0x41 + ! ( stable abi )
|
||||
AX POPx, AX AX ORxx, JZ, L1 @ RPCs, ( False, branch )
|
||||
( True, skip next 2 bytes and don't branch )
|
||||
L1 BSET ( loop will jump here ) DX INCx, DX INCx,
|
||||
;CODE NOP, NOP, NOP, NOP, NOP,
|
||||
DX INCx, DX INCx,
|
||||
;CODE
|
||||
|
9
blk/807
9
blk/807
@ -1,8 +1,9 @@
|
||||
CODE (loop) ( 0x80 )
|
||||
CODE (loop)
|
||||
PC 0x47 - ORG @ 0x45 + ! ( stable abi )
|
||||
[BP] 0 INC[w]+, ( I++ )
|
||||
( Jump if I <> I' )
|
||||
AX [BP] 0 MOVx[]+, AX [BP] -2 CMPx[]+,
|
||||
JNZ, L2 @ RPCs, ( branch )
|
||||
JNZ, L1 @ RPCs, ( branch )
|
||||
( don't branch )
|
||||
BP 4 SUBxi, JMPs, L1 @ RPCs,
|
||||
( END OF STABLE ABI )
|
||||
BP 4 SUBxi, DX INCx, DX INCx,
|
||||
;CODE
|
||||
|
BIN
cvm/forth.bin
BIN
cvm/forth.bin
Binary file not shown.
20
cvm/xcomp.fs
20
cvm/xcomp.fs
@ -18,17 +18,19 @@ ORG @ 0x2b + HERE !
|
||||
0 C, 0x06 C, ( (s) )
|
||||
ORG @ 0x33 + HERE !
|
||||
0 C, 0x04 C, ( 2>R )
|
||||
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
|
||||
ORG @ 0x4c + HERE !
|
||||
0x01 CODE (br) ( 0x53 )
|
||||
ORG @ 0x5f + HERE !
|
||||
0x02 CODE (?br) ( 0x67 )
|
||||
ORG @ 0x77 + HERE !
|
||||
0x03 CODE (loop) ( 0x80 )
|
||||
ORG @ 0xb9 + HERE !
|
||||
0x05 CODE (n) ( 0xbf )
|
||||
ORG @ 0x3b + HERE !
|
||||
0 C, 0x01 C, ( (br) )
|
||||
ORG @ 0x3f + HERE !
|
||||
0 C, 0x02 C, ( (?br) )
|
||||
ORG @ 0x43 + HERE !
|
||||
0 C, 0x03 C, ( (loop) )
|
||||
( END OF STABLE ABI )
|
||||
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
|
||||
0x00 CODE EXIT
|
||||
0x01 CODE (br)
|
||||
0x02 CODE (?br)
|
||||
0x03 CODE (loop)
|
||||
0x05 CODE (n)
|
||||
0x06 CODE (s)
|
||||
0x04 CODE 2>R
|
||||
0x07 CODE >R
|
||||
|
Loading…
Reference in New Issue
Block a user