mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 08:20:57 +11:00
Compare commits
No commits in common. "1094ec9c57de0363ccb481bce1ca5611e38bfcde" and "9ad7ee7a4b10e133ee6155e252b24480ca0b6565" have entirely different histories.
1094ec9c57
...
9ad7ee7a4b
5
blk/058
5
blk/058
@ -4,9 +4,10 @@ LIT -- Write a LIT entry. You're expected to write
|
|||||||
actual string to HERE right afterwards.
|
actual string to HERE right afterwards.
|
||||||
LIT< x -- Read following word and write to HERE as a
|
LIT< x -- Read following word and write to HERE as a
|
||||||
string literal.
|
string literal.
|
||||||
|
LITS a -- Write word at addr a as a atring literal.
|
||||||
S= a1 a2 -- f Returns whether string a1 == a2.
|
S= a1 a2 -- f Returns whether string a1 == a2.
|
||||||
SCPY a -- Copy string at addr a into HERE, without
|
SCPY a -- Copy string at addr a into HERE.
|
||||||
NULL termination.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4
blk/208
4
blk/208
@ -8,9 +8,9 @@ LD [rr, rn, ddnn, (nn)HL, HL(nn), dd(nn), (nn)dd, rIXY, IXYr,
|
|||||||
(DE)A, A(DE)]
|
(DE)A, A(DE)]
|
||||||
ADD [r, n, HLss, IXss, IXIX, IYss, IYIY]
|
ADD [r, n, HLss, IXss, IXIX, IYss, IYIY]
|
||||||
ADC [r, HLss]
|
ADC [r, HLss]
|
||||||
CP [r, n, (IXY+)]
|
CP [r, n]
|
||||||
SBC [r, HLss]
|
SBC [r, HLss]
|
||||||
SUB [r, n]
|
SUB [r, n]
|
||||||
PUSH [qq] POP [qq]
|
PUSH [qq] POP [qq]
|
||||||
INC [r, ss, (IXY+)] DEC [r, ss, (IXY+)]
|
INC [r, ss] DEC [r, ss]
|
||||||
AND [r, n] OR [r, n] XOR [r, n] (cont.)
|
AND [r, n] OR [r, n] XOR [r, n] (cont.)
|
||||||
|
2
blk/218
2
blk/218
@ -8,5 +8,3 @@
|
|||||||
OR A,
|
OR A,
|
||||||
;
|
;
|
||||||
0x04 OP1r INCr, 0x05 OP1r DECr,
|
0x04 OP1r INCr, 0x05 OP1r DECr,
|
||||||
: INC(IXY+), INCr, A, ;
|
|
||||||
: DEC(IXY+), DECr, A, ;
|
|
||||||
|
1
blk/219
1
blk/219
@ -11,4 +11,3 @@
|
|||||||
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, A, ;
|
|
||||||
|
2
blk/268
2
blk/268
@ -8,7 +8,7 @@
|
|||||||
DUP LIT< ( S= IF
|
DUP LIT< ( S= IF
|
||||||
DROP [COMPILE] (
|
DROP [COMPILE] (
|
||||||
ELSE
|
ELSE
|
||||||
SCPY 0x20 C,
|
SCPY 0x20 H@ 1- C!
|
||||||
THEN 0 ( loop again )
|
THEN 0 ( loop again )
|
||||||
ELSE 1 ( stop looping ) THEN
|
ELSE 1 ( stop looping ) THEN
|
||||||
UNTIL
|
UNTIL
|
||||||
|
8
blk/284
8
blk/284
@ -2,15 +2,11 @@
|
|||||||
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 )
|
0 A,, ( prev )
|
||||||
4 A,
|
4 A,
|
||||||
H@ XCURRENT ! ( set current tip of dict, 0x42 )
|
H@ XCURRENT ! ( set current tip of dict, 0x42 )
|
||||||
0x17 A, ( nativeWord )
|
0x17 A, ( nativeWord )
|
||||||
0x14 BCALL, ( popRS )
|
0x14 BCALL, ( popRS )
|
||||||
HL PUSHqq, IY POPqq, ( --> IP )
|
HL PUSHqq, IY POPqq, ( --> IP )
|
||||||
JPNEXT,
|
JPNEXT,
|
||||||
CODE (br) ( 0x53 )
|
|
||||||
L2 BSET ( used in CBR )
|
|
||||||
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
|
|
||||||
DE ADDIYss,
|
|
||||||
JPNEXT,
|
|
||||||
|
19
blk/285
19
blk/285
@ -1,15 +1,6 @@
|
|||||||
CODE (?br) ( 0x67 )
|
CODE (br) ( 0x53 )
|
||||||
HL POPqq, chkPS,
|
L2 BSET ( used in CBR )
|
||||||
HLZ,
|
E 0 IY+ LDrIXY,
|
||||||
JRZ, L2 BWR ( BR + 2. False, branch )
|
D 1 IY+ LDrIXY,
|
||||||
L1 BSET ( loop will jump here )
|
DE ADDIYss,
|
||||||
( True, skip next 2 bytes and don't branch )
|
|
||||||
IY INCss, IY INCss,
|
|
||||||
JPNEXT,
|
JPNEXT,
|
||||||
CODE (loop) ( 0x77 )
|
|
||||||
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 )
|
|
||||||
( don't branch )
|
|
||||||
IX DECss, IX DECss, IX DECss, IX DECss, JR, L1 BWR
|
|
||||||
|
28
blk/286
28
blk/286
@ -1,16 +1,12 @@
|
|||||||
CODE >R ( 0xa8 )
|
CODE (?br) ( 0x67 )
|
||||||
HL POPqq, chkPS,
|
HL POPqq,
|
||||||
17 BCALL, ( 17 == pushRS )
|
chkPS,
|
||||||
;CODE
|
HLZ,
|
||||||
CODE 2>R ( 0xb9 )
|
JRZ, L2 BWR ( BR + 2. False, branch )
|
||||||
DE POPqq, HL POPqq, chkPS,
|
( True, skip next 2 bytes and don't branch )
|
||||||
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
IY INCss,
|
||||||
;CODE
|
IY INCss,
|
||||||
CODE R> ( 0xce )
|
JPNEXT,
|
||||||
20 BCALL, ( 20 == popRS )
|
|
||||||
HL PUSHqq,
|
( END OF STABLE ABI )
|
||||||
;CODE
|
|
||||||
CODE 2R> ( 0xdc )
|
|
||||||
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
|
||||||
HL PUSHqq, DE PUSHqq,
|
|
||||||
;CODE ( END OF STABLE ABI )
|
|
||||||
|
2
blk/288
2
blk/288
@ -1,4 +1,4 @@
|
|||||||
PC ORG @ 0x22 + ! ( litWord, 0xf7, very tight on the 0x100 limit )
|
PC ORG @ 0x22 + ! ( litWord )
|
||||||
( Like numberWord, but instead of being followed by a 2 bytes
|
( Like numberWord, but instead of being followed by a 2 bytes
|
||||||
number, it's followed by a null-terminated string. When
|
number, it's followed by a null-terminated string. When
|
||||||
called, puts the string's address on PS )
|
called, puts the string's address on PS )
|
||||||
|
17
blk/326
Normal file
17
blk/326
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
CODE >R
|
||||||
|
HL POPqq, chkPS,
|
||||||
|
17 BCALL, ( 17 == pushRS )
|
||||||
|
;CODE
|
||||||
|
CODE 2>R
|
||||||
|
DE POPqq, HL POPqq, chkPS,
|
||||||
|
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
||||||
|
;CODE
|
||||||
|
CODE R>
|
||||||
|
20 BCALL, ( 20 == popRS )
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
CODE 2R>
|
||||||
|
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
||||||
|
HL PUSHqq, DE PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
10
blk/391
10
blk/391
@ -9,8 +9,8 @@ unusable directly. For the same reason, any reference to a word
|
|||||||
in the host system will obviously be wrong in the target
|
in the host system will obviously be wrong in the target
|
||||||
system. More details in B260.
|
system. More details in B260.
|
||||||
|
|
||||||
These rules result in some practicals do's and dont's:
|
This unit is loaded in two "low" and "high" parts. The low part
|
||||||
|
is the biggest chunk and has the most definitions. The high
|
||||||
1. No LEAVE in DO..LOOP
|
part is the "sensitive" chunk and contains "LITN", ":" and ";"
|
||||||
|
definitions which, once defined, kind of make any more defs
|
||||||
(cont.)
|
impossible. (cont.)
|
||||||
|
6
blk/392
6
blk/392
@ -1,9 +1,3 @@
|
|||||||
This unit is loaded in two "low" and "high" parts. The low part
|
|
||||||
is the biggest chunk and has the most definitions. The high
|
|
||||||
part is the "sensitive" chunk and contains "LITN", ":" and ";"
|
|
||||||
definitions which, once defined, kind of make any more defs
|
|
||||||
impossible.
|
|
||||||
|
|
||||||
The gap between these 2 parts is the ideal place to put device
|
The gap between these 2 parts is the ideal place to put device
|
||||||
driver code. Load the low part with "393 LOAD", the high part
|
driver code. Load the low part with "393 LOAD", the high part
|
||||||
with "415 LOAD"
|
with "415 LOAD"
|
||||||
|
14
blk/407
14
blk/407
@ -1,6 +1,10 @@
|
|||||||
: SCPY
|
: SCPY
|
||||||
BEGIN ( a )
|
BEGIN ( a )
|
||||||
C@+ ( a+1 c )
|
DUP C@ ( a c )
|
||||||
DUP NOT IF 2DROP EXIT THEN
|
DUP C, ( a c )
|
||||||
C, ( a c )
|
NOT IF DROP EXIT THEN
|
||||||
AGAIN ;
|
1+ ( a+1 )
|
||||||
|
AGAIN
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
12
blk/408
12
blk/408
@ -1,10 +1,14 @@
|
|||||||
: [entry]
|
: [entry]
|
||||||
HERE @ ( w h )
|
HERE @ ( w h )
|
||||||
SWAP SCPY ( h )
|
SWAP SCPY ( h )
|
||||||
HERE @ SWAP - ( sz )
|
( Adjust HERE -1 because SCPY copies the null )
|
||||||
|
HERE @ 1- ( h h' )
|
||||||
|
DUP HERE ! ( h h' )
|
||||||
|
SWAP - ( sz )
|
||||||
( write prev value )
|
( write prev value )
|
||||||
HERE @ CURRENT @ - ,
|
HERE @ CURRENT @ - ,
|
||||||
C, ( write size )
|
( write size )
|
||||||
|
C,
|
||||||
HERE @ CURRENT !
|
HERE @ CURRENT !
|
||||||
;
|
;
|
||||||
|
|
||||||
|
7
blk/412
7
blk/412
@ -1,6 +1,3 @@
|
|||||||
( Words here until the end of the low part, unlike words
|
|
||||||
preceeding them, aren't immediately needed for boot. But its
|
|
||||||
better to have as many words as possible in the xcomp part. )
|
|
||||||
: H@ HERE @ ;
|
: H@ HERE @ ;
|
||||||
: IMMEDIATE
|
: IMMEDIATE
|
||||||
CURRENT @ 1-
|
CURRENT @ 1-
|
||||||
@ -8,8 +5,4 @@
|
|||||||
;
|
;
|
||||||
: +! SWAP OVER @ + SWAP ! ;
|
: +! SWAP OVER @ + SWAP ! ;
|
||||||
: -^ SWAP - ;
|
: -^ SWAP - ;
|
||||||
: / /MOD SWAP DROP ;
|
|
||||||
: MOD /MOD DROP ;
|
|
||||||
|
|
||||||
: ALLOT HERE +! ;
|
: ALLOT HERE +! ;
|
||||||
: CREATE (entry) 11 ( 11 == cellWord ) C, ;
|
|
||||||
|
3
blk/422
3
blk/422
@ -1,6 +1,7 @@
|
|||||||
: [ INTERPRET ; IMMEDIATE
|
: [ INTERPRET ; IMMEDIATE
|
||||||
: ] R> DROP ;
|
: ] R> DROP ;
|
||||||
: LIT< WORD 34 , SCPY 0 C, ; IMMEDIATE
|
: LITS 34 , SCPY ;
|
||||||
|
: LIT< WORD LITS ; IMMEDIATE
|
||||||
: LITA 36 , , ;
|
: LITA 36 , , ;
|
||||||
: '? WORD (find) ;
|
: '? WORD (find) ;
|
||||||
: '
|
: '
|
||||||
|
2
blk/424
2
blk/424
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
40 is ASCII for '('. We do this to simplify XPACK's task of
|
40 is ASCII for '('. We do this to simplify XPACK's task of
|
||||||
not mistakenly consider '(' definition as a comment.
|
not mistakenly consider '(' definition as a comment.
|
||||||
LIT<: 34 == litWord
|
LITS: 34 == litWord
|
||||||
LITA: 36 == addrWord
|
LITA: 36 == addrWord
|
||||||
COMPILE: Tough one. Get addr of caller word (example above
|
COMPILE: Tough one. Get addr of caller word (example above
|
||||||
(br)) and then call LITA on it. )
|
(br)) and then call LITA on it. )
|
||||||
|
7
blk/429
Normal file
7
blk/429
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
: CREATE
|
||||||
|
(entry) ( empty header with name )
|
||||||
|
11 ( 11 == cellWord )
|
||||||
|
C, ( write it )
|
||||||
|
;
|
||||||
|
|
||||||
|
|
6
blk/431
6
blk/431
@ -1,8 +1,10 @@
|
|||||||
: VARIABLE CREATE 2 ALLOT ;
|
: VARIABLE CREATE 2 ALLOT ;
|
||||||
: CONSTANT CREATE , DOES> @ ;
|
: CONSTANT CREATE , DOES> @ ;
|
||||||
|
: / /MOD SWAP DROP ;
|
||||||
|
: MOD /MOD DROP ;
|
||||||
|
|
||||||
( In addition to pushing H@ this compiles 2>R so that loop
|
( In addition to pushing H@ this compiles 2>R so that loop
|
||||||
variables are sent to PS at runtime )
|
variables are sent to PS at runtime )
|
||||||
: DO COMPILE 2>R H@ ; IMMEDIATE
|
: DO COMPILE 2>R H@ ; IMMEDIATE
|
||||||
: LOOP COMPILE (loop) H@ - , ; IMMEDIATE
|
|
||||||
: LEAVE R> R> DROP I 1- >R >R ;
|
|
||||||
|
16
blk/432
Normal file
16
blk/432
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
( Increase loop counter and returns whether we should loop. )
|
||||||
|
: _
|
||||||
|
R> ( IP, keep for later )
|
||||||
|
R> 1+ ( ip i+1 )
|
||||||
|
DUP >R ( ip i )
|
||||||
|
I' = ( ip f )
|
||||||
|
SWAP >R ( f )
|
||||||
|
;
|
||||||
|
( One could think that we should have a sub word to avoid all
|
||||||
|
these COMPILE, but we can't because otherwise it messes with
|
||||||
|
the RS )
|
||||||
|
: LOOP
|
||||||
|
COMPILE _ COMPILE (?br)
|
||||||
|
H@ - ,
|
||||||
|
COMPILE 2R> COMPILE 2DROP
|
||||||
|
; IMMEDIATE
|
2
blk/433
2
blk/433
@ -1,3 +1,5 @@
|
|||||||
|
: LEAVE R> R> DROP I 1- >R >R ;
|
||||||
|
|
||||||
: ROLL
|
: ROLL
|
||||||
DUP NOT IF EXIT THEN
|
DUP NOT IF EXIT THEN
|
||||||
1+ DUP PICK ( n val )
|
1+ DUP PICK ( n val )
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user