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

Remove indirect memory access

I got bitten again, I've over-designed my solution. The last time
it happened, it was that memory mapping thing I was wanting to add.

The indirect memory access feature I was adding was to solve a
specific problem: Allow Collapse OS to cross-compile directly on a
AT28 EEPROM.

It began well. As long as we were staying in the assembler realm,
things were looking good. However, when we got into the xcomp realm
(B260), things became ugly, and I had to creep up indirection where
I didn't want to.

All of this because I wanted to solve my initial problem in a
slightly more generalized way. The broad idea was that these indirect
memory access could allow xcomp into a broad kind of memory-like
devices.

This idea broke on the "@" part of the equation. If I want
indirections to be two-way and allow xcomp to work properly, I have
to add this indirection to FIND (and possibly others) and this just
isn't practical or elegant.

So, I'm taking a step back and accepting that the solution I design
for now is exclusively for the AT28. What I'm thinking is to add a
low-level hook for memory writing, at the assembly level.
This commit is contained in:
Virgil Dupras 2020-12-07 22:18:10 -05:00
parent 80d1b59050
commit 45eceaaf61
6 changed files with 115 additions and 160 deletions

225
blk.fs
View File

@ -54,19 +54,16 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: CPO 4 ; : CPE 5 ; : CP 6 ; : CM 7 ; : CPO 4 ; : CPE 5 ; : CP 6 ; : CM 7 ;
( ----- 007 ) ( ----- 007 )
: PC H@ ORG @ - BIN( @ + ; : PC H@ ORG @ - BIN( @ + ;
( C,* spits an assembled byte, A,, spits an assembled word
Both increase PC. )
: A,, |L C,* C,* ;
: <<3 3 LSHIFT ; : <<4 4 LSHIFT ; : <<3 3 LSHIFT ; : <<4 4 LSHIFT ;
( As a general rule, IX and IY are equivalent to spitting an ( As a general rule, IX and IY are equivalent to spitting an
extra 0xdd / 0xfd and then spit the equivalent of HL ) extra 0xdd / 0xfd and then spit the equivalent of HL )
: IX 0xdd C,* HL ; : IY 0xfd C,* HL ; : IX 0xdd C, HL ; : IY 0xfd C, HL ;
: _ix+- 0xff AND 0xdd C,* (HL) ; : _ix+- 0xff AND 0xdd C, (HL) ;
: _iy+- 0xff AND 0xfd C,* (HL) ; : _iy+- 0xff AND 0xfd C, (HL) ;
: IX+ _ix+- ; : IX- 0 -^ _ix+- ; : IX+ _ix+- ; : IX- 0 -^ _ix+- ;
: IY+ _iy+- ; : IY- 0 -^ _iy+- ; : IY+ _iy+- ; : IY- 0 -^ _iy+- ;
( ----- 008 ) ( ----- 008 )
: OP1 CREATE C, DOES> C@ C,* ; : OP1 CREATE C, DOES> C@ C, ;
0xf3 OP1 DI, 0xfb OP1 EI, 0xf3 OP1 DI, 0xfb OP1 EI,
0xeb OP1 EXDEHL, 0xd9 OP1 EXX, 0xeb OP1 EXDEHL, 0xd9 OP1 EXX,
0x08 OP1 EXAFAF', 0xe3 OP1 EX(SP)HL, 0x08 OP1 EXAFAF', 0xe3 OP1 EX(SP)HL,
@ -95,22 +92,22 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
C@ ( r op ) C@ ( r op )
SWAP ( op r ) SWAP ( op r )
<<3 ( op r<<3 ) <<3 ( op r<<3 )
OR C,* OR C,
; ;
0x04 OP1r INCr, 0x05 OP1r DECr, 0x04 OP1r INCr, 0x05 OP1r DECr,
: INC(IXY+), INCr, C,* ; : INC(IXY+), INCr, C, ;
: DEC(IXY+), DECr, C,* ; : DEC(IXY+), DECr, C, ;
( also works for c ) ( also works for c )
0xc0 OP1r RETc, 0xc0 OP1r RETc,
( ----- 011 ) ( ----- 011 )
: OP1r0 ( r -- ) : OP1r0 ( r -- )
CREATE C, DOES> CREATE C, DOES>
C@ ( r op ) OR C,* ; C@ ( r op ) OR C, ;
0x80 OP1r0 ADDr, 0x88 OP1r0 ADCr, 0x80 OP1r0 ADDr, 0x88 OP1r0 ADCr,
0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr, 0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr,
0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr, 0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr,
0x98 OP1r0 SBCr, 0xa8 OP1r0 XORr, 0x98 OP1r0 SBCr, 0xa8 OP1r0 XORr,
: CP(IXY+), CPr, C,* ; : CP(IXY+), CPr, C, ;
( ----- 012 ) ( ----- 012 )
: OP1d : OP1d
CREATE C, CREATE C,
@ -118,20 +115,20 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
C@ ( d op ) C@ ( d op )
SWAP ( op d ) SWAP ( op d )
<<4 ( op d<<4 ) <<4 ( op d<<4 )
OR C,* OR C,
; ;
0xc5 OP1d PUSH, 0xc1 OP1d POP, 0xc5 OP1d PUSH, 0xc1 OP1d POP,
0x03 OP1d INCd, 0x0b OP1d DECd, 0x03 OP1d INCd, 0x0b OP1d DECd,
0x09 OP1d ADDHLd, 0x09 OP1d ADDHLd,
: ADDIXd, 0xdd C,* ADDHLd, ; : ADDIXIX, HL ADDIXd, ; : ADDIXd, 0xdd C, ADDHLd, ; : ADDIXIX, HL ADDIXd, ;
: ADDIYd, 0xfd C,* ADDHLd, ; : ADDIYIY, HL ADDIYd, ; : ADDIYd, 0xfd C, ADDHLd, ; : ADDIYIY, HL ADDIYd, ;
( ----- 013 ) ( ----- 013 )
: _1rr : _1rr
C@ ( rd rr op ) C@ ( rd rr op )
ROT ( rr op rd ) ROT ( rr op rd )
<<3 ( rr op rd<<3 ) <<3 ( rr op rd<<3 )
OR OR C,* OR OR C,
; ;
( rd rr ) ( rd rr )
@ -146,7 +143,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: LDIXYr, : LDIXYr,
( dd/fd has already been spit ) ( dd/fd has already been spit )
LDrr, ( ixy+- ) LDrr, ( ixy+- )
C,* C,
; ;
( rd ixy+- HL ) ( rd ixy+- HL )
@ -156,7 +153,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
LDIXYr, LDIXYr,
; ;
( ----- 015 ) ( ----- 015 )
: OP2 CREATE , DOES> @ |M C,* C,* ; : OP2 CREATE , DOES> @ |M C, C, ;
0xeda1 OP2 CPI, 0xedb1 OP2 CPIR, 0xeda1 OP2 CPI, 0xedb1 OP2 CPIR,
0xeda9 OP2 CPD, 0xedb9 OP2 CPDR, 0xeda9 OP2 CPD, 0xedb9 OP2 CPDR,
0xed46 OP2 IM0, 0xed56 OP2 IM1, 0xed46 OP2 IM0, 0xed56 OP2 IM1,
@ -169,7 +166,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OP2i ( i -- ) : OP2i ( i -- )
CREATE C, CREATE C,
DOES> DOES>
C@ C,* C,* C@ C, C,
; ;
0xd3 OP2i OUTiA, 0xd3 OP2i OUTiA,
0xdb OP2i INAi, 0xdb OP2i INAi,
@ -186,7 +183,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
C@ ( r i op ) C@ ( r i op )
ROT ( i op r ) ROT ( i op r )
<<3 ( i op r<<3 ) <<3 ( i op r<<3 )
OR C,* C,* OR C, C,
; ;
0x06 OP2ri LDri, 0x06 OP2ri LDri,
( ----- 018 ) ( ----- 018 )
@ -194,11 +191,11 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OP2br : OP2br
CREATE C, CREATE C,
DOES> DOES>
0xcb C,* 0xcb C,
C@ ( b r op ) C@ ( b r op )
ROT ( r op b ) ROT ( r op b )
<<3 ( r op b<<3 ) <<3 ( r op b<<3 )
OR OR C,* OR OR C,
; ;
0xc0 OP2br SET, 0xc0 OP2br SET,
0x80 OP2br RES, 0x80 OP2br RES,
@ -208,9 +205,9 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OProt ( r -- ) : OProt ( r -- )
CREATE C, CREATE C,
DOES> DOES>
0xcb C,* 0xcb C,
C@ ( r op ) C@ ( r op )
OR C,* OR C,
; ;
0x10 OProt RL, 0x10 OProt RL,
0x00 OProt RLC, 0x00 OProt RLC,
@ -225,10 +222,10 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OP2r : OP2r
CREATE , CREATE ,
DOES> DOES>
@ |M ( r lsb msb ) @ |M ( r lsb msb )
C,* ( r lsb ) C, ( r lsb )
SWAP <<3 ( lsb r<<3 ) SWAP <<3 ( lsb r<<3 )
OR C,* OR C,
; ;
0xed41 OP2r OUT(C)r, 0xed41 OP2r OUT(C)r,
0xed40 OP2r INr(C), 0xed40 OP2r INr(C),
@ -236,10 +233,10 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OP2d ( d -- ) : OP2d ( d -- )
CREATE C, CREATE C,
DOES> DOES>
0xed C,* 0xed C,
C@ SWAP ( op d ) C@ SWAP ( op d )
<<4 ( op d<< 4 ) <<4 ( op d<< 4 )
OR C,* OR C,
; ;
0x4a OP2d ADCHLd, 0x4a OP2d ADCHLd,
0x42 OP2d SBCHLd, 0x42 OP2d SBCHLd,
@ -251,8 +248,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
C@ ( d n op ) C@ ( d n op )
ROT ( n op d ) ROT ( n op d )
<<4 ( n op d<<4 ) <<4 ( n op d<<4 )
OR C,* OR C, ,
A,,
; ;
0x01 OP3di LDdi, 0x01 OP3di LDdi,
( ----- 023 ) ( ----- 023 )
@ -260,8 +256,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OP3i : OP3i
CREATE C, CREATE C,
DOES> DOES>
C@ C,* C@ C, ,
A,,
; ;
0xcd OP3i CALL, 0xcd OP3i CALL,
0xc3 OP3i JP, 0xc3 OP3i JP,
@ -269,21 +264,19 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
0x32 OP3i LD(i)A, 0x3a OP3i LDA(i), 0x32 OP3i LD(i)A, 0x3a OP3i LDA(i),
( ----- 024 ) ( ----- 024 )
: LDd(i), ( d i -- ) : LDd(i), ( d i -- )
0xed C,* 0xed C,
SWAP <<4 0x4b OR C,* SWAP <<4 0x4b OR C, ,
A,,
; ;
: LD(i)d, ( i d -- ) : LD(i)d, ( i d -- )
0xed C,* 0xed C,
<<4 0x43 OR C,* <<4 0x43 OR C, ,
A,,
; ;
: RST, 0xc7 OR C,* ; : RST, 0xc7 OR C, ;
: JP(IX), IX DROP JP(HL), ; : JP(IX), IX DROP JP(HL), ;
: JP(IY), IY DROP JP(HL), ; : JP(IY), IY DROP JP(HL), ;
( ----- 025 ) ( ----- 025 )
: JPc, SWAP <<3 0xc2 OR C,* A,, ; : JPc, SWAP <<3 0xc2 OR C, , ;
: BCALL, BIN( @ + CALL, ; : BCALL, BIN( @ + CALL, ;
: BJP, BIN( @ + JP, ; : BJP, BIN( @ + JP, ;
: BJPc, BIN( @ + JPc, ; : BJPc, BIN( @ + JPc, ;
@ -301,7 +294,7 @@ CREATE lblnext 0 , ( stable ABI until set in B300 )
: BEGIN, PC ; : BEGIN, PC ;
: BSET PC SWAP ! ; : BSET PC SWAP ! ;
( same as BSET, but we need to write a placeholder ) ( same as BSET, but we need to write a placeholder )
: FJR, PC 0 C,* ; : FJR, PC 0 C, ;
: IFZ, JRNZ, FJR, ; : IFZ, JRNZ, FJR, ;
: IFNZ, JRZ, FJR, ; : IFNZ, JRZ, FJR, ;
: IFC, JRNC, FJR, ; : IFC, JRNC, FJR, ;
@ -311,15 +304,15 @@ CREATE lblnext 0 , ( stable ABI until set in B300 )
-^ 1- ( l off ) -^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! ) ( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + BIN( @ - ( off addr ) SWAP ORG @ + BIN( @ - ( off addr )
C!* ; C! ;
( ----- 027 ) ( ----- 027 )
: FWR BSET 0 C,* ; : FWR BSET 0 C, ;
: FSET @ THEN, ; : FSET @ THEN, ;
: BREAK, FJR, 0x8000 OR ; : BREAK, FJR, 0x8000 OR ;
: BREAK?, DUP 0x8000 AND IF : BREAK?, DUP 0x8000 AND IF
0x7fff AND 1 ALLOT THEN, -1 ALLOT 0x7fff AND 1 ALLOT THEN, -1 ALLOT
THEN ; THEN ;
: AGAIN, BREAK?, PC - 1- C,* ; : AGAIN, BREAK?, PC - 1- C, ;
: BWR @ AGAIN, ; : BWR @ AGAIN, ;
( ----- 028 ) ( ----- 028 )
( Macros ) ( Macros )
@ -351,9 +344,8 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: <<3 3 LSHIFT ; : <<3 3 LSHIFT ;
( ----- 032 ) ( ----- 032 )
: PC H@ ORG @ - BIN( @ + ; : PC H@ ORG @ - BIN( @ + ;
: A,, |L C,* C,* ;
( ----- 033 ) ( ----- 033 )
: OP1 CREATE C, DOES> C@ C,* ; : OP1 CREATE C, DOES> C@ C, ;
0xc3 OP1 RET, 0xfa OP1 CLI, 0xfb OP1 STI, 0xc3 OP1 RET, 0xfa OP1 CLI, 0xfb OP1 STI,
0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD, 0xf4 OP1 HLT, 0xfc OP1 CLD, 0xfd OP1 STD,
0x90 OP1 NOP, 0x98 OP1 CBW, 0x90 OP1 NOP, 0x98 OP1 CBW,
@ -366,12 +358,12 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
0x75 OP1 JNZ, 0x72 OP1 JC, 0x73 OP1 JNC, 0x75 OP1 JNZ, 0x72 OP1 JC, 0x73 OP1 JNC,
0xe8 OP1 CALL, 0xe8 OP1 CALL,
: OP1r CREATE C, DOES> C@ + C,* ; : OP1r CREATE C, DOES> C@ + C, ;
0x40 OP1r INCx, 0x48 OP1r DECx, 0x40 OP1r INCx, 0x48 OP1r DECx,
0x58 OP1r POPx, 0x50 OP1r PUSHx, 0x58 OP1r POPx, 0x50 OP1r PUSHx,
( ----- 034 ) ( ----- 034 )
: OPr0 ( reg op ) CREATE C, C, DOES> : OPr0 ( reg op ) CREATE C, C, DOES>
C@+ C,* C@ <<3 OR 0xc0 OR C,* ; C@+ C, C@ <<3 OR 0xc0 OR C, ;
0 0xd0 OPr0 ROLr1, 0 0xd1 OPr0 ROLx1, 4 0xf6 OPr0 MULr, 0 0xd0 OPr0 ROLr1, 0 0xd1 OPr0 ROLx1, 4 0xf6 OPr0 MULr,
1 0xd0 OPr0 RORr1, 1 0xd1 OPr0 RORx1, 4 0xf7 OPr0 MULx, 1 0xd0 OPr0 RORr1, 1 0xd1 OPr0 RORx1, 4 0xf7 OPr0 MULx,
4 0xd0 OPr0 SHLr1, 4 0xd1 OPr0 SHLx1, 6 0xf6 OPr0 DIVr, 4 0xd0 OPr0 SHLr1, 4 0xd1 OPr0 SHLx1, 6 0xf6 OPr0 DIVr,
@ -381,65 +373,65 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
4 0xd2 OPr0 SHLrCL, 4 0xd3 OPr0 SHLxCL, 4 0xd2 OPr0 SHLrCL, 4 0xd3 OPr0 SHLxCL,
5 0xd2 OPr0 SHRrCL, 5 0xd3 OPr0 SHRxCL, 5 0xd2 OPr0 SHRrCL, 5 0xd3 OPr0 SHRxCL,
( ----- 035 ) ( ----- 035 )
: OPrr CREATE C, DOES> C@ C,* <<3 OR 0xc0 OR C,* ; : OPrr CREATE C, DOES> C@ C, <<3 OR 0xc0 OR C, ;
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,
0x38 OPrr CMPrr, 0x39 OPrr CMPxx, 0x00 OPrr ADDrr, 0x38 OPrr CMPrr, 0x39 OPrr CMPxx, 0x00 OPrr ADDrr,
0x01 OPrr ADDxx, 0x20 OPrr ANDrr, 0x21 OPrr ANDxx, 0x01 OPrr ADDxx, 0x20 OPrr ANDrr, 0x21 OPrr ANDxx,
( ----- 036 ) ( ----- 036 )
: OPm ( modrm op ) CREATE C, C, DOES> C@+ C,* C@ OR C,* ; : OPm ( modrm op ) CREATE C, C, DOES> C@+ C, C@ OR C, ;
0 0xff OPm INC[w], 0 0xfe OPm INC[b], 0 0xff OPm INC[w], 0 0xfe OPm INC[b],
0x8 0xff OPm DEC[w], 0x8 0xfe OPm DEC[b], 0x8 0xff OPm DEC[w], 0x8 0xfe OPm DEC[b],
0x30 0xff OPm PUSH[w], 0 0x8f OPm POP[w], 0x30 0xff OPm PUSH[w], 0 0x8f OPm POP[w],
: OPm+ ( modrm op ) CREATE C, C, DOES> : OPm+ ( modrm op ) CREATE C, C, DOES>
( m off ) C@+ C,* C@ ROT OR C,* C,* ; ( m off ) C@+ C, C@ ROT OR C, C, ;
0x40 0xff OPm+ INC[w]+, 0x40 0xfe OPm+ INC[b]+, 0x40 0xff OPm+ INC[w]+, 0x40 0xfe OPm+ INC[b]+,
0x48 0xff OPm+ DEC[w]+, 0x48 0xfe OPm+ DEC[b]+, 0x48 0xff OPm+ DEC[w]+, 0x48 0xfe OPm+ DEC[b]+,
0x70 0xff OPm+ PUSH[w]+, 0x40 0x8f OPm+ POP[w]+, 0x70 0xff OPm+ PUSH[w]+, 0x40 0x8f OPm+ POP[w]+,
( ----- 037 ) ( ----- 037 )
: OPrm CREATE C, DOES> C@ C,* SWAP 3 LSHIFT OR C,* ; : OPrm CREATE C, DOES> C@ C, SWAP 3 LSHIFT OR C, ;
0x8a OPrm MOVr[], 0x8b OPrm MOVx[], 0x8a OPrm MOVr[], 0x8b OPrm MOVx[],
0x3a OPrm CMPr[], 0x3b OPrm CMPx[], 0x3a OPrm CMPr[], 0x3b OPrm CMPx[],
: OPmr CREATE C, DOES> C@ C,* 3 LSHIFT OR C,* ; : OPmr CREATE C, DOES> C@ C, 3 LSHIFT OR C, ;
0x88 OPmr MOV[]r, 0x89 OPmr MOV[]x, 0x88 OPmr MOV[]r, 0x89 OPmr MOV[]x,
: OPrm+ ( r m off ) CREATE C, DOES> : OPrm+ ( r m off ) CREATE C, DOES>
C@ C,* ROT 3 LSHIFT ROT OR 0x40 OR C,* C,* ; C@ C, ROT 3 LSHIFT ROT OR 0x40 OR C, C, ;
0x8a OPrm+ MOVr[]+, 0x8b OPrm+ MOVx[]+, 0x8a OPrm+ MOVr[]+, 0x8b OPrm+ MOVx[]+,
0x3a OPrm+ CMPr[]+, 0x3b OPrm+ CMPx[]+, 0x3a OPrm+ CMPr[]+, 0x3b OPrm+ CMPx[]+,
: OPm+r ( m off r ) CREATE C, DOES> : OPm+r ( m off r ) CREATE C, DOES>
C@ C,* 3 LSHIFT ROT OR 0x40 OR C,* C,* ; C@ C, 3 LSHIFT ROT OR 0x40 OR C, C, ;
0x88 OPm+r MOV[]+r, 0x89 OPm+r MOV[]+x, 0x88 OPm+r MOV[]+r, 0x89 OPm+r MOV[]+x,
( ----- 038 ) ( ----- 038 )
: OPi CREATE C, DOES> C@ C,* C,* ; : OPi CREATE C, DOES> C@ C, C, ;
0x04 OPi ADDALi, 0x24 OPi ANDALi, 0x2c OPi SUBALi, 0x04 OPi ADDALi, 0x24 OPi ANDALi, 0x2c OPi SUBALi,
0xcd OPi INT, 0xcd OPi INT,
: OPI CREATE C, DOES> C@ C,* A,, ; : OPI CREATE C, DOES> C@ C, , ;
0x05 OPI ADDAXI, 0x25 OPI ANDAXI, 0x2d OPI SUBAXI, 0x05 OPI ADDAXI, 0x25 OPI ANDAXI, 0x2d OPI SUBAXI,
( ----- 040 ) ( ----- 040 )
: MOVri, SWAP 0xb0 OR C,* C,* ; : MOVri, SWAP 0xb0 OR C, C, ;
: MOVxI, SWAP 0xb8 OR C,* A,, ; : MOVxI, SWAP 0xb8 OR C, , ;
: MOVsx, 0x8e C,* SWAP <<3 OR 0xc0 OR C,* ; : MOVsx, 0x8e C, SWAP <<3 OR 0xc0 OR C, ;
: MOVrm, 0x8a C,* SWAP <<3 0x6 OR C,* A,, ; : MOVrm, 0x8a C, SWAP <<3 0x6 OR C, , ;
: MOVxm, 0x8b C,* SWAP <<3 0x6 OR C,* A,, ; : MOVxm, 0x8b C, SWAP <<3 0x6 OR C, , ;
: MOVmr, 0x88 C,* <<3 0x6 OR C,* A,, ; : MOVmr, 0x88 C, <<3 0x6 OR C, , ;
: MOVmx, 0x89 C,* <<3 0x6 OR C,* A,, ; : MOVmx, 0x89 C, <<3 0x6 OR C, , ;
: PUSHs, <<3 0x06 OR C,* ; : POPs, <<3 0x07 OR C,* ; : PUSHs, <<3 0x06 OR C, ; : POPs, <<3 0x07 OR C, ;
: SUBxi, 0x83 C,* SWAP 0xe8 OR C,* C,* ; : SUBxi, 0x83 C, SWAP 0xe8 OR C, C, ;
: ADDxi, 0x83 C,* SWAP 0xc0 OR C,* C,* ; : ADDxi, 0x83 C, SWAP 0xc0 OR C, C, ;
: JMPr, 0xff C,* 7 AND 0xe0 OR C,* ; : JMPr, 0xff C, 7 AND 0xe0 OR C, ;
: JMPf, ( seg off ) 0xea C,* |L C,* C,* A,, ; : JMPf, ( seg off ) 0xea C, |L C, C, , ;
( ----- 041 ) ( ----- 041 )
( Place BEGIN, where you want to jump back and AGAIN after ( Place BEGIN, where you want to jump back and AGAIN after
a relative jump operator. Just like BSET and BWR. ) a relative jump operator. Just like BSET and BWR. )
: BEGIN, PC ; : BEGIN, PC ;
: BSET PC SWAP ! ; : BSET PC SWAP ! ;
( same as BSET, but we need to write a placeholder ) ( same as BSET, but we need to write a placeholder )
: FJR, PC 0 C,* ; : FJR, PC 0 C, ;
: IFZ, JNZ, FJR, ; : IFZ, JNZ, FJR, ;
: IFNZ, JZ, FJR, ; : IFNZ, JZ, FJR, ;
: IFC, JNC, FJR, ; : IFC, JNC, FJR, ;
@ -449,13 +441,13 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
-^ 1- ( l off ) -^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! ) ( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + BIN( @ - ( off addr ) SWAP ORG @ + BIN( @ - ( off addr )
C!* ; C! ;
( ----- 042 ) ( ----- 042 )
: FWRs BSET 0 C,* ; : FWRs BSET 0 C, ;
: FSET @ THEN, ; : FSET @ THEN, ;
( TODO: add BREAK, ) ( TODO: add BREAK, )
: RPCs, PC - 1- DUP 128 + 0xff > IF ABORT" PC ovfl" THEN C,* ; : RPCs, PC - 1- DUP 128 + 0xff > IF ABORT" PC ovfl" THEN C, ;
: RPCn, PC - 2- A,, ; : RPCn, PC - 2- , ;
: AGAIN, ( BREAK?, ) RPCs, ; : AGAIN, ( BREAK?, ) RPCs, ;
( Use RPCx with appropriate JMP/CALL op. Example: ( Use RPCx with appropriate JMP/CALL op. Example:
JMPs, 0x42 RPCs, or CALL, 0x1234 RPCn, ) JMPs, 0x42 RPCs, or CALL, 0x1234 RPCn, )
@ -474,9 +466,6 @@ VARIABLE ORG
VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4 VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
( We divide by 2 because each PC represents a word. ) ( We divide by 2 because each PC represents a word. )
: PC H@ ORG @ - 1 RSHIFT ; : PC H@ ORG @ - 1 RSHIFT ;
( C,* spits an assembled byte, A,, spits an assembled word
Both increase PC. )
: A,, |L C,* C,* ;
( ----- 052 ) ( ----- 052 )
: _oor ." arg out of range: " .X SPC ." PC: " PC .X NL ABORT ; : _oor ." arg out of range: " .X SPC ." PC: " PC .X NL ABORT ;
: _r8c DUP 7 > IF _oor THEN ; : _r8c DUP 7 > IF _oor THEN ;
@ -487,7 +476,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: _Rdp ( op rd -- op', place Rd ) 4 LSHIFT OR ; : _Rdp ( op rd -- op', place Rd ) 4 LSHIFT OR ;
( ----- 053 ) ( ----- 053 )
( 0000 000d dddd 0000 ) ( 0000 000d dddd 0000 )
: OPRd CREATE , DOES> @ SWAP _r32c _Rdp A,, ; : OPRd CREATE , DOES> @ SWAP _r32c _Rdp , ;
0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM, 0b1001010000000101 OPRd ASR, 0b1001010000000000 OPRd COM,
0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC, 0b1001010000001010 OPRd DEC, 0b1001010000000011 OPRd INC,
0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS, 0b1001001000000110 OPRd LAC, 0b1001001000000101 OPRd LAS,
@ -501,7 +490,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
: OPRdRr CREATE C, DOES> C@ ( rd rr op ) : OPRdRr CREATE C, DOES> C@ ( rd rr op )
OVER _r32c 0x10 AND 3 RSHIFT OR ( rd rr op' ) OVER _r32c 0x10 AND 3 RSHIFT OR ( rd rr op' )
8 LSHIFT OR 0xff0f AND ( rd op' ) 8 LSHIFT OR 0xff0f AND ( rd op' )
SWAP _r32c _Rdp A,, ; SWAP _r32c _Rdp , ;
0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND, 0x1c OPRdRr ADC, 0x0c OPRdRr ADD, 0x20 OPRdRr AND,
0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE, 0x14 OPRdRr CP, 0x04 OPRdRr CPC, 0x10 OPRdRr CPSE,
0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL, 0x24 OPRdRr EOR, 0x2c OPRdRr MOV, 0x9c OPRdRr MUL,
@ -510,24 +499,24 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
( 0000 0AAd dddd AAAA ) ( 0000 0AAd dddd AAAA )
: OPRdA CREATE C, DOES> C@ ( rd A op ) : OPRdA CREATE C, DOES> C@ ( rd A op )
OVER _r64c 0x30 AND 3 RSHIFT OR ( rd A op' ) OVER _r64c 0x30 AND 3 RSHIFT OR ( rd A op' )
8 LSHIFT OR 0xff0f AND ( rd op' ) SWAP _r32c _Rdp A,, ; 8 LSHIFT OR 0xff0f AND ( rd op' ) SWAP _r32c _Rdp , ;
0xb0 OPRdA IN, 0xb8 OPRdA _ : OUT, SWAP _ ; 0xb0 OPRdA IN, 0xb8 OPRdA _ : OUT, SWAP _ ;
( ----- 055 ) ( ----- 055 )
( 0000 KKKK dddd KKKK ) ( 0000 KKKK dddd KKKK )
: OPRdK CREATE C, DOES> C@ ( rd K op ) : OPRdK CREATE C, DOES> C@ ( rd K op )
OVER _r256c 0xf0 AND 4 RSHIFT OR ( rd K op' ) OVER _r256c 0xf0 AND 4 RSHIFT OR ( rd K op' )
ROT _r16+c 4 LSHIFT ROT 0x0f AND OR ( op' rdK ) C,* C,* ; ROT _r16+c 4 LSHIFT ROT 0x0f AND OR ( op' rdK ) C, C, ;
0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0xe0 OPRdK LDI, 0x70 OPRdK ANDI, 0x30 OPRdK CPI, 0xe0 OPRdK LDI,
0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR, 0x60 OPRdK ORI, 0x40 OPRdK SBCI, 0x60 OPRdK SBR,
0x50 OPRdK SUBI, 0x50 OPRdK SUBI,
( 0000 0000 AAAA Abbb ) ( 0000 0000 AAAA Abbb )
: OPAb CREATE C, DOES> C@ ( A b op ) : OPAb CREATE C, DOES> C@ ( A b op )
ROT _r32c 3 LSHIFT ROT _r8c OR C,* C,* ; ROT _r32c 3 LSHIFT ROT _r8c OR C, C, ;
0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC, 0x98 OPAb CBI, 0x9a OPAb SBI, 0x99 OPAb SBIC,
0x9b OPAb SBIS, 0x9b OPAb SBIS,
( ----- 056 ) ( ----- 056 )
: OPNA CREATE , DOES> @ A,, ; : OPNA CREATE , DOES> @ , ;
0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH, 0x9598 OPNA BREAK, 0x9488 OPNA CLC, 0x94d8 OPNA CLH,
0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS, 0x94f8 OPNA CLI, 0x94a8 OPNA CLN, 0x94c8 OPNA CLS,
0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ, 0x94e8 OPNA CLT, 0x94b8 OPNA CLV, 0x9498 OPNA CLZ,
@ -540,12 +529,12 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
( ----- 057 ) ( ----- 057 )
( 0000 0000 0sss 0000 ) ( 0000 0000 0sss 0000 )
: OPb CREATE , DOES> @ ( b op ) : OPb CREATE , DOES> @ ( b op )
SWAP _r8c _Rdp A,, ; SWAP _r8c _Rdp , ;
0b1001010010001000 OPb BCLR, 0b1001010000001000 OPb BSET, 0b1001010010001000 OPb BCLR, 0b1001010000001000 OPb BSET,
( 0000 000d dddd 0bbb ) ( 0000 000d dddd 0bbb )
: OPRdb CREATE , DOES> @ ( rd b op ) : OPRdb CREATE , DOES> @ ( rd b op )
ROT _r32c _Rdp SWAP _r8c OR A,, ; ROT _r32c _Rdp SWAP _r8c OR , ;
0b1111100000000000 OPRdb BLD, 0b1111101000000000 OPRdb BST, 0b1111100000000000 OPRdb BLD, 0b1111101000000000 OPRdb BST,
0b1111110000000000 OPRdb SBRC, 0b1111111000000000 OPRdb SBRS, 0b1111110000000000 OPRdb SBRC, 0b1111111000000000 OPRdb SBRS,
@ -558,7 +547,7 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ; PC - DUP 0< IF 0x800 + _r7ffc 0x800 OR ELSE _r7ffc THEN ;
: RJMP _raddr12 0xc000 OR ; : RJMP _raddr12 0xc000 OR ;
: RCALL _raddr12 0xd000 OR ; : RCALL _raddr12 0xd000 OR ;
: RJMP, RJMP A,, ; : RCALL, RCALL A,, ; : RJMP, RJMP , ; : RCALL, RCALL , ;
( ----- 059 ) ( ----- 059 )
( a -- k7, absolute addr a, relative to PC in a k7 addr ) ( a -- k7, absolute addr a, relative to PC in a k7 addr )
: _r3fc DUP 0x3f > IF _oor THEN ; : _r3fc DUP 0x3f > IF _oor THEN ;
@ -576,22 +565,22 @@ VARIABLE L1 VARIABLE L2 VARIABLE L3 VARIABLE L4
0b11101 CONSTANT X+ 0b11001 CONSTANT Y+ 0b10001 CONSTANT Z+ 0b11101 CONSTANT X+ 0b11001 CONSTANT Y+ 0b10001 CONSTANT Z+
0b11110 CONSTANT -X 0b11010 CONSTANT -Y 0b10010 CONSTANT -Z 0b11110 CONSTANT -X 0b11010 CONSTANT -Y 0b10010 CONSTANT -Z
: _ldst ( Rd XYZ op ) SWAP DUP 0x10 AND 8 LSHIFT SWAP 0xf AND : _ldst ( Rd XYZ op ) SWAP DUP 0x10 AND 8 LSHIFT SWAP 0xf AND
OR OR ( Rd op' ) SWAP _Rdp A,, ; OR OR ( Rd op' ) SWAP _Rdp , ;
: LD, 0x8000 _ldst ; : ST, SWAP 0x8200 _ldst ; : LD, 0x8000 _ldst ; : ST, SWAP 0x8200 _ldst ;
( ----- 061 ) ( ----- 061 )
( L1 LBL! .. L1 ' RJMP LBL, ) ( L1 LBL! .. L1 ' RJMP LBL, )
: LBL! ( l -- ) PC SWAP ! ; : LBL! ( l -- ) PC SWAP ! ;
: LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE A,, ; : LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE , ;
: SKIP, PC 0 A,, ; : SKIP, PC 0 , ;
: TO, ( opw pc ) ( TODO: use !* instead of ! ) : TO, ( opw pc ) ( TODO: use !* instead of ! )
( warning: pc is a PC offset, not a mem addr! ) ( warning: pc is a PC offset, not a mem addr! )
2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp ) 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp )
ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp ) ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp )
HERE ! ; HERE ! ;
( L1 FLBL, .. L1 ' RJMP FLBL! ) ( L1 FLBL, .. L1 ' RJMP FLBL! )
: FLBL, ( l -- ) LBL! 0 A,, ; : FLBL, ( l -- ) LBL! 0 , ;
: FLBL! ( l opw -- ) SWAP @ TO, ; : FLBL! ( l opw -- ) SWAP @ TO, ;
: BEGIN, PC ; : AGAIN?, ( op ) SWAP 1- SWAP EXECUTE A,, ; : BEGIN, PC ; : AGAIN?, ( op ) SWAP 1- SWAP EXECUTE , ;
: AGAIN, ['] RJMP AGAIN?, ; : AGAIN, ['] RJMP AGAIN?, ;
: IF, ['] BREQ SKIP, ; : THEN, TO, ; : IF, ['] BREQ SKIP, ; : THEN, TO, ;
( ----- 062 ) ( ----- 062 )
@ -945,16 +934,16 @@ VARIABLE aspprevx
0xc0 ( b msb lsb 0xc0 ) _cmd DROP asprdy ; 0xc0 ( b msb lsb 0xc0 ) _cmd DROP asprdy ;
( ----- 165 ) ( ----- 165 )
( Sega ROM signer. See doc/sega.txt ) ( Sega ROM signer. See doc/sega.txt )
: C!*+^ ( a c -- a+1 ) OVER C!* 1+ ; : C!+^ ( a c -- a+1 ) OVER C! 1+ ;
: segasig ( addr size -- ) : segasig ( addr size -- )
0x2000 OVER LSHIFT ( a sz bytesz ) 0x2000 OVER LSHIFT ( a sz bytesz )
ROT TUCK + 0x10 - ( sz a end ) ROT TUCK + 0x10 - ( sz a end )
TUCK SWAP 0 ROT> ( sz end sum end a ) DO ( sz end sum ) TUCK SWAP 0 ROT> ( sz end sum end a ) DO ( sz end sum )
I C@* + LOOP ( sz end sum ) SWAP ( sz sum end ) I C@ + LOOP ( sz end sum ) SWAP ( sz sum end )
'T' C!*+^ 'M' C!*+^ 'R' C!*+^ 0x20 C!*+^ 'S' C!*+^ 'T' C!+^ 'M' C!+^ 'R' C!+^ 0x20 C!+^ 'S' C!+^
'E' C!*+^ 'G' C!*+^ 'A' C!*+^ 0 C!*+^ 0 C!*+^ 'E' C!+^ 'G' C!+^ 'A' C!+^ 0 C!+^ 0 C!+^
( sum's LSB ) OVER C!*+^ ( MSB ) SWAP 8 RSHIFT OVER C!* 1+ ( sum's LSB ) OVER C!+^ ( MSB ) SWAP 8 RSHIFT OVER C! 1+
( sz end ) 0 C!*+^ 0 C!*+^ 0 C!*+^ SWAP 0x4a + SWAP C!* ; ( sz end ) 0 C!+^ 0 C!+^ 0 C!+^ SWAP 0x4a + SWAP C! ;
( ----- 260 ) ( ----- 260 )
Cross compilation program Cross compilation program
@ -1068,9 +1057,9 @@ NOP, NOP, NOP, NOP, NOP, NOP, ( unused )
0 JP, ( RST 10 ) NOP, NOP, ( 13, oflw ) 0 JP, ( RST 10 ) NOP, NOP, ( 13, oflw )
NOP, NOP, NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, NOP, NOP, ( unused )
0 JP, ( 1a, next ) NOP, NOP, NOP, ( unused ) 0 JP, ( 1a, next ) NOP, NOP, NOP, ( unused )
0 JP, ( RST 20 ) 0 C,* 0 C,* 0 C,* 0 C,* 0 C,* ( unused ) 0 JP, ( RST 20 ) 5 ALLOT0
0 JP, ( RST 28 ) 0 C,* 0 C,* 0 C,* 0 C,* 0 C,* ( unused ) 0 JP, ( RST 28 ) 5 ALLOT0
0 JP, ( RST 30 ) 0 C,* 0 C,* 0 C,* 0 C,* 0 C,* ( unused ) 0 JP, ( RST 30 ) 5 ALLOT0
0 JP, ( RST 38 ) 0 JP, ( RST 38 )
( ----- 284 ) ( ----- 284 )
PC ORG @ 1 + ! ( main ) PC ORG @ 1 + ! ( main )
@ -1726,12 +1715,9 @@ with "390 LOAD"
: / /MOD NIP ; : / /MOD NIP ;
: MOD /MOD DROP ; : MOD /MOD DROP ;
: ALLOT HERE +! ; : ALLOT HERE +! ;
SYSVARS 0x3e + :** C@*
SYSVARS 0x40 + :** C!*
SYSVARS 0x42 + :** C,*
: FILL ( a n b -- ) : FILL ( a n b -- )
ROT> OVER ( b a n a ) + SWAP ( b a+n a ) DO ( b ) ROT> OVER ( b a n a ) + SWAP ( b a+n a ) DO ( b )
DUP I C!* LOOP DROP ; DUP I C! LOOP DROP ;
: ALLOT0 ( n -- ) H@ OVER 0 FILL ALLOT ; : ALLOT0 ( n -- ) H@ OVER 0 FILL ALLOT ;
( ----- 356 ) ( ----- 356 )
SYSVARS 0x53 + :** EMIT SYSVARS 0x53 + :** EMIT
@ -1865,23 +1851,23 @@ SYSVARS 0x0c + :** C<*
( ----- 367 ) ( ----- 367 )
: MOVE ( a1 a2 u -- ) : MOVE ( a1 a2 u -- )
?DUP IF ( u ) 0 DO ( a1 a2 ) ?DUP IF ( u ) 0 DO ( a1 a2 )
OVER I + C@* ( src dst x ) OVER I + C@ ( src dst x )
OVER I + ( src dst x dst ) OVER I + ( src dst x dst )
C!* ( src dst ) C! ( src dst )
LOOP THEN 2DROP ; LOOP THEN 2DROP ;
: MOVE- ( a1 a2 u -- ) : MOVE- ( a1 a2 u -- )
?DUP IF ( u ) 0 DO ( a1 a2 ) ?DUP IF ( u ) 0 DO ( a1 a2 )
OVER I' + I - 1- C@* ( src dst x ) OVER I' + I - 1- C@ ( src dst x )
OVER I' + I - 1- ( src dst x dst ) OVER I' + I - 1- ( src dst x dst )
C!* ( src dst ) C! ( src dst )
LOOP THEN 2DROP ; LOOP THEN 2DROP ;
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ; : MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
( ----- 368 ) ( ----- 368 )
: MOVEW ( src dst u -- ) : MOVEW ( src dst u -- )
( u ) 0 DO ( u ) 0 DO
SWAP DUP I 1 LSHIFT + C@* ( dst src x ) SWAP DUP I 1 LSHIFT + C@ ( dst src x )
ROT TUCK I 1 LSHIFT + ( src dst x dst ) ROT TUCK I 1 LSHIFT + ( src dst x dst )
C!* ( src dst ) C! ( src dst )
LOOP 2DROP ; LOOP 2DROP ;
: PREV 3 - DUP @ - ; : PREV 3 - DUP @ - ;
: [entry] ( w -- ) : [entry] ( w -- )
@ -2120,7 +2106,6 @@ SYSVARS 0x55 + :** KEY
['] (emit) ['] EMIT **! ['] (key) ['] KEY **! ['] (emit) ['] EMIT **! ['] (key) ['] KEY **!
['] CRLF ['] NL **! ['] CRLF ['] NL **!
['] (boot<) ['] C<* **! ['] (boot<) ['] C<* **!
['] C@ ['] C@* **! ['] C! ['] C!* **! ['] C, ['] C,* **!
( boot< always has a char waiting. 06 == C<?* ) ( boot< always has a char waiting. 06 == C<?* )
1 0x06 RAM+ ! INTERPRET 1 0x06 RAM+ ! INTERPRET
RDLN$ LIT" _sys" [entry] RDLN$ LIT" _sys" [entry]
@ -2526,13 +2511,13 @@ Load range: B445-B461
( ----- 445 ) ( ----- 445 )
VARIABLE lblexec VARIABLE lblnext VARIABLE lblexec VARIABLE lblnext
H@ ORG ! H@ ORG !
JMPn, 0 A,, ( 00, main ) 0 C,* ( 03, boot driveno ) JMPn, 0 , ( 00, main ) 0 C, ( 03, boot driveno )
0 A,, ( 04, BOOT ) 0 , ( 04, BOOT )
0 A,, ( 06, uflw ) 0 A,, ( 08, LATEST ) 0 A,, ( unused ) 0 , ( 06, uflw ) 0 , ( 08, LATEST ) 0 , ( unused )
0 C,* 0 A,, ( 0b, EXIT ) 0 C, 0 , ( 0b, EXIT )
0 A,, 0 A,, ( unused ) 0 A,, ( 13, oflw ) 0 , 0 , ( unused ) 0 , ( 13, oflw )
0 A,, 0 A,, 0 C,* ( unused ) 0 , 0 , 0 C, ( unused )
JMPn, 0 A,, ( 1a, next ) JMPn, 0 , ( 1a, next )
( ----- 446 ) ( ----- 446 )
( TODO: move these words with other native words. ) ( TODO: move these words with other native words. )
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field ) H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )

Binary file not shown.

View File

@ -50,10 +50,6 @@ $ - Initialize
aborts. aborts.
['] x -- *I* Like "'", but spits the addr as a number ['] x -- *I* Like "'", but spits the addr as a number
literal. If not found, aborts. literal. If not found, aborts.
, n -- Write n in HERE and advance it.
ALLOT n -- Move HERE by n bytes
C, b -- Write byte b in HERE and advance it.
C,* b -- Indirect C,
FIND w -- a f Like '?, but for w. FIND w -- a f Like '?, but for w.
EMPTY -- Rewind HERE and CURRENT where they were at EMPTY -- Rewind HERE and CURRENT where they were at
system initialization. system initialization.
@ -153,18 +149,19 @@ J -- n Copy RS third item to PS
@ a -- n Set n to value at address a @ a -- n Set n to value at address a
! n a -- Store n in address a ! n a -- Store n in address a
, n -- Write n in HERE and advance it.
? a -- Print value of addr a ? a -- Print value of addr a
+! n a -- Increase value of addr a by n +! n a -- Increase value of addr a by n
C@ a -- c Set c to byte at address a C@ a -- c Set c to byte at address a
C@* a -- c Indirect C@
C@+ a -- a+1 c Fetch c from a and inc a. C@+ a -- a+1 c Fetch c from a and inc a.
C@- a -- a-1 c Fetch c from a and dec a. C@- a -- a-1 c Fetch c from a and dec a.
C! c a -- Store byte c in address a C! c a -- Store byte c in address a
C!* c a -- Indirect C!
C!+ c a -- a+1 Store byte c in a and inc a. C!+ c a -- a+1 Store byte c in a and inc a.
C!- c a -- a-1 Store byte c in a and dec a. C!- c a -- a-1 Store byte c in a and dec a.
C, b -- Write byte b in HERE and advance it.
*! a al -- Change alias al's addr to a. *! a al -- Change alias al's addr to a.
**! a sw -- Change ialias sw's addr to a. **! a sw -- Change ialias sw's addr to a.
ALLOT n -- Move HERE by n bytes
CURRENT -- a Set a to wordref of last added entry. CURRENT -- a Set a to wordref of last added entry.
CURRENT* -- a A pointer to active CURRENT*. Useful CURRENT* -- a A pointer to active CURRENT*. Useful
when we have multiple active dicts. when we have multiple active dicts.
@ -178,9 +175,6 @@ MOVE- a1 a2 u -- Copy u bytes from a1 to a2, starting
MOVE, a u -- Copy u bytes from a to HERE. MOVE, a u -- Copy u bytes from a to HERE.
MOVEW src dst u -- Same as MOVE, but with words MOVEW src dst u -- Same as MOVE, but with words
Important note: MOVE* use C@* and C!* instead of C@ and C! See
"Indirect memory access" in usage.txt.
MOVEW notes: this word's purpose is to interface with word- MOVEW notes: this word's purpose is to interface with word-
based systems. src and dst are addressed as *bytes* but u is a based systems. src and dst are addressed as *bytes* but u is a
*word* count. Every iteration increases src and dst by 2. This *word* count. Every iteration increases src and dst by 2. This
@ -258,9 +252,8 @@ WORD -- a Read one word from buffered input and push its
There are also ascii const emitters: There are also ascii const emitters:
BS CR LF SPC CRLF BS CR LF SPC CRLF
NL is an indirect word (see SYSVARS in impl.txt) that aliases to NL is an ialias that points to CRLF by default and that should
CRLF by default and that should generally be used when we want generally be used when we want to emit a newline.
to emit a newline.
# Disk # Disk

View File

@ -159,9 +159,9 @@ offsets, but thankfully, there aren't many system variables.
Here's a list of them: Here's a list of them:
SYSVARS FUTURE USES +3c BLK(* SYSVARS FUTURE USES +3c BLK(*
+02 CURRENT +3e C@* +02 CURRENT +3e FUTURE USES
+04 HERE +40 C!* +04 HERE +40 FUTURE USES
+06 C<? +42 C,* +06 C<? +42 FUTURE USES
+08 C<* override +44 FUTURE USES +08 C<* override +44 FUTURE USES
+0a NL ialias +51 CURRENTPTR +0a NL ialias +51 CURRENTPTR
+0c C<* +53 EMIT ialias +0c C<* +53 EMIT ialias
@ -191,10 +191,7 @@ address. Most of the time, it points to RAM+2, but sometimes,
when maintaining alternative dicts (during cross compilation when maintaining alternative dicts (during cross compilation
for example), it can point elsewhere. for example), it can point elsewhere.
NLPTR points to an alternative routine for NL (by default, BLK* "Disk blocks" in usage.txt.
CRLF).
BLK* see B416.
DRIVERS section is reserved for recipe-specific drivers. DRIVERS section is reserved for recipe-specific drivers.
@ -226,9 +223,6 @@ few things:
EMIT -> (emit) EMIT -> (emit)
KEY -> (key) KEY -> (key)
NL -> CRLF NL -> CRLF
C@* -> C@
C!* -> C!
C,* -> C,
3. Set "C<*", the word that C< calls, to (boot<). 3. Set "C<*", the word that C< calls, to (boot<).
4. Call INTERPRET which interprets boot source code until 4. Call INTERPRET which interprets boot source code until
ASCII EOT (4) is met. This usually initializes drivers. ASCII EOT (4) is met. This usually initializes drivers.

View File

@ -82,23 +82,6 @@ addresses in RAM (because the core code is designed to run from
ROM, we can't have regular variables). You are unlikely to ROM, we can't have regular variables). You are unlikely to
need ialiases in regular code. need ialiases in regular code.
Aliases and ialiases generally have their name end with "*".
Core words such as KEY and EMIT, which are ialiases, are
exceptions.
# Indirect memory access
C@*, C!*, and C,* are the indirect versions of C@, C! and C,.
They are ialias words and initially point to C@, C! and C,.
Indirect memory access words can be useful to "pipe" processing
to places outside of regular memory.
Many core words, such as MOVE, use indirect memory access. This
gives a lot of flexibility to those words, allowing for complex
data transfers. The cost of the indirection is small because of
the optimized ways aliases are built.
# Disk blocks # Disk blocks
Disk blocks are Collapse OS' main access to permanent storage. Disk blocks are Collapse OS' main access to permanent storage.

View File

@ -42,7 +42,7 @@ int main(int argc, char **argv)
} }
char s[0x40]; char s[0x40];
sprintf(s, sprintf(s,
": _ 0x%04x 0x%04x DO KEY DUP .x I C!* LOOP ; _", ": _ 0x%04x 0x%04x DO KEY DUP .x I C! LOOP ; _",
memptr+bytecount, memptr); memptr+bytecount, memptr);
sendcmd(fd, s); sendcmd(fd, s);