Compare commits
5 Commits
98d23bc59b
...
53c9580944
Author | SHA1 | Date | |
---|---|---|---|
|
53c9580944 | ||
|
9b01e16f6d | ||
|
cc59d37658 | ||
|
a776df27d2 | ||
|
c668433c5d |
24
blk/328
24
blk/328
@ -1,14 +1,16 @@
|
|||||||
CODE S=
|
CODE S=
|
||||||
DE POPqq,
|
DE POPqq, HL POPqq, chkPS,
|
||||||
HL POPqq,
|
HL DECss, DE DECss,
|
||||||
chkPS,
|
LDA(DE),
|
||||||
BEGIN,
|
(HL) CPr,
|
||||||
LDA(DE),
|
IFZ, ( same size? )
|
||||||
(HL) CPr,
|
B A LDrr, ( loop A times )
|
||||||
JRNZ, BREAK, ( not equal? break early. NZ is set. )
|
BEGIN,
|
||||||
A ORr, ( if our char is null, stop )
|
HL INCss, DE INCss,
|
||||||
HL INCss,
|
LDA(DE),
|
||||||
DE INCss,
|
(HL) CPr,
|
||||||
JRNZ, AGAIN,
|
JRNZ, BREAK, ( not equal? break early. NZ is set. )
|
||||||
|
DJNZ, AGAIN,
|
||||||
|
THEN,
|
||||||
PUSHZ,
|
PUSHZ,
|
||||||
;CODE
|
;CODE
|
||||||
|
1
blk/354
1
blk/354
@ -11,3 +11,4 @@
|
|||||||
: C!+ ( c a -- a+1 ) TUCK C! 1+ ;
|
: C!+ ( c a -- a+1 ) TUCK C! 1+ ;
|
||||||
: C@- ( a -- a-1 c ) DUP C@ SWAP 1- SWAP ;
|
: C@- ( a -- a-1 c ) DUP C@ SWAP 1- SWAP ;
|
||||||
: C!- ( c a -- a-1 ) TUCK C! 1- ;
|
: C!- ( c a -- a-1 ) TUCK C! 1- ;
|
||||||
|
: LEAVE R> R> DROP I 1- >R >R ; : UNLOOP R> 2R> 2DROP >R ;
|
||||||
|
25
blk/357
25
blk/357
@ -1,16 +1,11 @@
|
|||||||
: (parsed) ( a -- n f )
|
: _ ( a len -- n f )
|
||||||
DUP C@ ( a c )
|
OVER C@ ( a len c )
|
||||||
DUP '-' = IF
|
'-' = IF
|
||||||
DROP 1+ ( a+1 ) (parsed) 0 ROT ( f 0 n )
|
1- SWAP 1+ SWAP ( a+1 len-1 ) _ 0 ROT ( f 0 n )
|
||||||
- SWAP EXIT ( 0-n f )
|
- SWAP EXIT ( 0-n f )
|
||||||
THEN
|
THEN ( a len )
|
||||||
0 SWAP _pdacc ( a r f )
|
0 SWAP ( len ) 0 DO ( a r )
|
||||||
?DUP IF 2DROP 0 EXIT THEN
|
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
||||||
BEGIN ( a r )
|
IF DROP 0 UNLOOP EXIT THEN LOOP ( a r )
|
||||||
SWAP 1+ ( r a+1 )
|
NIP 1 ;
|
||||||
DUP C@ ( r a c )
|
: (parsed) ( a -- n f ) DUP 1- C@ ( a l ) _ ;
|
||||||
ROT SWAP ( a r c )
|
|
||||||
_pdacc ( a r f )
|
|
||||||
?DUP UNTIL
|
|
||||||
1 = ( a r f )
|
|
||||||
ROT DROP ( r f ) ;
|
|
||||||
|
17
blk/360
17
blk/360
@ -2,14 +2,9 @@
|
|||||||
( '0': ASCII 0x30 'x': 0x78 0x7830: 30768 )
|
( '0': ASCII 0x30 'x': 0x78 0x7830: 30768 )
|
||||||
DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 )
|
DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 )
|
||||||
( We have "0x" prefix )
|
( We have "0x" prefix )
|
||||||
2+
|
DUP 1- C@ ( a len )
|
||||||
0 ( a r )
|
0 SWAP ( len ) 2 DO ( a r )
|
||||||
BEGIN
|
OVER I + C@ ( a r c ) _ ( a r n )
|
||||||
SWAP C@+ ( r a+1 c )
|
DUP 0< IF 2DROP 0 UNLOOP EXIT THEN
|
||||||
?DUP NOT IF DROP 1 EXIT THEN ( r, 1 )
|
SWAP 4 LSHIFT + ( a r*16+n ) LOOP
|
||||||
_ ( r a n )
|
NIP 1 ;
|
||||||
DUP 0< IF ROT 2DROP 0 EXIT THEN ( a 0 )
|
|
||||||
ROT 16 * + ( a r*16+n )
|
|
||||||
AGAIN
|
|
||||||
;
|
|
||||||
|
|
||||||
|
18
blk/362
18
blk/362
@ -2,15 +2,9 @@
|
|||||||
( '0': ASCII 0x30 'b': 0x62 0x6230: 25136 )
|
( '0': ASCII 0x30 'b': 0x62 0x6230: 25136 )
|
||||||
DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 )
|
DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 )
|
||||||
( We have "0b" prefix )
|
( We have "0b" prefix )
|
||||||
2+
|
DUP 1- C@ ( a len )
|
||||||
0 ( a r )
|
0 SWAP ( len ) 2 DO ( a r )
|
||||||
BEGIN
|
OVER I + C@ ( a r c ) _ ( a r n )
|
||||||
SWAP C@+ ( r a+1 c )
|
DUP 0< IF 2DROP 0 UNLOOP EXIT THEN
|
||||||
?DUP NOT IF DROP 1 EXIT THEN ( r 1 )
|
SWAP 1 LSHIFT + ( a r*2+n ) LOOP
|
||||||
_ ( r a n )
|
NIP 1 ;
|
||||||
DUP 0< IF ROT 2DROP 0 EXIT THEN ( a 0 )
|
|
||||||
ROT 2 * + ( a r*2+n )
|
|
||||||
AGAIN
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
9
blk/367
Normal file
9
blk/367
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
: IMMEDIATE
|
||||||
|
CURRENT @ 1-
|
||||||
|
DUP C@ 128 OR SWAP C! ;
|
||||||
|
: IMMED? 1- C@ 0x80 AND ;
|
||||||
|
: +! TUCK @ + SWAP ! ;
|
||||||
|
: -^ SWAP - ;
|
||||||
|
: / /MOD NIP ;
|
||||||
|
: MOD /MOD DROP ;
|
||||||
|
: ALLOT HERE +! ;
|
12
blk/368
12
blk/368
@ -1,12 +0,0 @@
|
|||||||
: +! TUCK @ + SWAP ! ;
|
|
||||||
: [entry] ( w -- )
|
|
||||||
H@ SWAP
|
|
||||||
BEGIN C@+ ( w+1 c ) ?DUP IF C, 0 ELSE 1 THEN UNTIL DROP
|
|
||||||
H@ SWAP - ( sz )
|
|
||||||
( write prev value )
|
|
||||||
H@ CURRENT @ - ,
|
|
||||||
C, ( write size )
|
|
||||||
H@ CURRENT !
|
|
||||||
;
|
|
||||||
|
|
||||||
: (entry) WORD [entry] ;
|
|
23
blk/369
23
blk/369
@ -1,11 +1,12 @@
|
|||||||
: IMMEDIATE
|
: '? WORD FIND ;
|
||||||
CURRENT @ 1-
|
: '
|
||||||
DUP C@ 128 OR SWAP C! ;
|
'? (?br) [ 4 , ] EXIT
|
||||||
: IMMED? 1- C@ 0x80 AND ;
|
LIT< (wnf) FIND DROP EXECUTE
|
||||||
: -^ SWAP - ;
|
;
|
||||||
: / /MOD NIP ;
|
: ROLL
|
||||||
: MOD /MOD DROP ;
|
?DUP NOT IF EXIT THEN
|
||||||
: ALLOT HERE +! ;
|
1+ DUP PICK ( n val )
|
||||||
: CREATE (entry) 11 ( 11 == cellWord ) C, ;
|
SWAP 2 * (roll) ( val )
|
||||||
: VARIABLE CREATE 2 ALLOT ;
|
NIP ;
|
||||||
: LEAVE R> R> DROP I 1- >R >R ;
|
: 2OVER 3 PICK 3 PICK ;
|
||||||
|
: 2SWAP 3 ROLL 3 ROLL ;
|
||||||
|
26
blk/370
26
blk/370
@ -1,12 +1,14 @@
|
|||||||
: '? WORD FIND ;
|
: MOVE ( a1 a2 u -- )
|
||||||
: '
|
( u ) 0 DO ( a1 a2 )
|
||||||
'? (?br) [ 4 , ] EXIT
|
SWAP C@+ ( a2 a1+1 x )
|
||||||
LIT< (wnf) FIND DROP EXECUTE
|
ROT C!+ ( a1+1 a2+1 )
|
||||||
;
|
LOOP 2DROP ;
|
||||||
: ROLL
|
: MOVE- ( a1 a2 u -- )
|
||||||
?DUP NOT IF EXIT THEN
|
TUCK + 1- ( a1 u a2+u-1 )
|
||||||
1+ DUP PICK ( n val )
|
ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 )
|
||||||
SWAP 2 * (roll) ( val )
|
ROT ( u ) 0 DO ( a2 a1 )
|
||||||
NIP ;
|
C@- ( a2 a1-1 x )
|
||||||
: 2OVER 3 PICK 3 PICK ;
|
ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 )
|
||||||
: 2SWAP 3 ROLL 3 ROLL ;
|
LOOP 2DROP ;
|
||||||
|
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
||||||
|
: PREV 3 - DUP @ - ;
|
||||||
|
24
blk/371
24
blk/371
@ -1,14 +1,10 @@
|
|||||||
: MOVE ( a1 a2 u -- )
|
: [entry] ( w -- )
|
||||||
( u ) 0 DO ( a1 a2 )
|
1- C@+ ( w+1 len ) TUCK MOVE, ( len )
|
||||||
SWAP C@+ ( a2 a1+1 x )
|
( write prev value )
|
||||||
ROT C!+ ( a1+1 a2+1 )
|
H@ CURRENT @ - ,
|
||||||
LOOP 2DROP ;
|
C, ( write size )
|
||||||
: MOVE- ( a1 a2 u -- )
|
H@ CURRENT !
|
||||||
TUCK + 1- ( a1 u a2+u-1 )
|
;
|
||||||
ROT 2 PICK + 1- ( u a2+u-1 a1+u-1 )
|
: (entry) WORD [entry] ;
|
||||||
ROT ( u ) 0 DO ( a2 a1 )
|
: CREATE (entry) 11 ( 11 == cellWord ) C, ;
|
||||||
C@- ( a2 a1-1 x )
|
: VARIABLE CREATE 2 ALLOT ;
|
||||||
ROT C!- ( a1-1 a2-1 ) SWAP ( a2 a1 )
|
|
||||||
LOOP 2DROP ;
|
|
||||||
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
|
||||||
: PREV 3 - DUP @ - ;
|
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
@ -42,7 +42,8 @@ static uint8_t iord_stdio()
|
|||||||
|
|
||||||
static void iowr_stdio(uint8_t val)
|
static void iowr_stdio(uint8_t val)
|
||||||
{
|
{
|
||||||
// we don't output stdout in stage0
|
// uncomment when you need to debug staging
|
||||||
|
// putc(val, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iowr_here(uint8_t val)
|
static void iowr_here(uint8_t val)
|
||||||
|
Loading…
Reference in New Issue
Block a user