Compare commits
No commits in common. "04335fc40a735b9772d292edc298be3e087cb656" and "53c9580944f6e267e41bd043a19ee8c56dba6f70" have entirely different histories.
04335fc40a
...
53c9580944
4
blk/288
4
blk/288
@ -4,7 +4,7 @@ PC ORG @ 0x22 + ! ( litWord, 0xf7, tight on the 0x100 limit )
|
||||
called, puts the string's address on PS )
|
||||
IY PUSHqq, HL POPqq, ( <-- IP )
|
||||
E (HL) LDrr, D 0 LDrn,
|
||||
DE INCss,
|
||||
DE INCss, DE INCss,
|
||||
DE ADDIYss,
|
||||
HL PUSHqq,
|
||||
HL INCss, HL PUSHqq,
|
||||
JPNEXT,
|
||||
|
2
blk/289
2
blk/289
@ -1,5 +1,5 @@
|
||||
( Name of BOOT word )
|
||||
L1 BSET 4 A, 'B' A, 'O' A, 'O' A, 'T' A,
|
||||
4 A, L1 BSET 'B' A, 'O' A, 'O' A, 'T' A,
|
||||
|
||||
PC ORG @ 1 + ! ( main )
|
||||
( STACK OVERFLOW PROTECTION: See B76 )
|
||||
|
2
blk/291
2
blk/291
@ -5,7 +5,7 @@ PC ORG @ 4 + ! ( find )
|
||||
BC PUSHqq,
|
||||
HL PUSHqq,
|
||||
( First, figure out string len )
|
||||
A (HL) LDrr, A ORr,
|
||||
HL DECss, A (HL) LDrr, A ORr,
|
||||
( special case. zero len? we never find anything. )
|
||||
IFNZ, ( fail-B296 )
|
||||
( Let's do something weird: We'll hold HL by the *tail*.
|
||||
|
2
blk/298
2
blk/298
@ -1,6 +1,6 @@
|
||||
6 A, '(' A, 'u' A, 'f' A, 'l' A, 'w' A, ')' A,
|
||||
L2 BSET ( abortUnderflow )
|
||||
HL PC 7 - LDddnn,
|
||||
HL PC 6 - LDddnn,
|
||||
DE RAMSTART 0x02 + LDdd(nn), ( RAM+02 == CURRENT )
|
||||
0x03 BCALL, ( find )
|
||||
0x33 BJP, ( 33 == execute )
|
||||
|
1
blk/328
1
blk/328
@ -1,5 +1,6 @@
|
||||
CODE S=
|
||||
DE POPqq, HL POPqq, chkPS,
|
||||
HL DECss, DE DECss,
|
||||
LDA(DE),
|
||||
(HL) CPr,
|
||||
IFZ, ( same size? )
|
||||
|
6
blk/357
6
blk/357
@ -1,4 +1,4 @@
|
||||
: _ ( a+1 len -- n f )
|
||||
: _ ( a len -- n f )
|
||||
OVER C@ ( a len c )
|
||||
'-' = IF
|
||||
1- SWAP 1+ SWAP ( a+1 len-1 ) _ 0 ROT ( f 0 n )
|
||||
@ -6,6 +6,6 @@
|
||||
THEN ( a len )
|
||||
0 SWAP ( len ) 0 DO ( a r )
|
||||
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
||||
IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
||||
IF DROP 0 UNLOOP EXIT THEN LOOP ( a r )
|
||||
NIP 1 ;
|
||||
: (parsed) ( a -- n f ) C@+ ( a+1 l ) _ ;
|
||||
: (parsed) ( a -- n f ) DUP 1- C@ ( a l ) _ ;
|
||||
|
4
blk/358
4
blk/358
@ -3,9 +3,9 @@
|
||||
|
||||
: (parsec) ( a -- n f )
|
||||
( apostrophe is ASCII 39 )
|
||||
DUP 1+ C@ 39 = OVER 3 + C@ 39 = AND ( a f )
|
||||
DUP C@ 39 = OVER 2+ C@ 39 = AND ( a f )
|
||||
NOT IF 0 EXIT THEN ( a 0 )
|
||||
( surrounded by apos, good, return )
|
||||
2+ C@ 1 ( n 1 )
|
||||
1+ C@ 1 ( n 1 )
|
||||
;
|
||||
|
||||
|
8
blk/360
8
blk/360
@ -1,9 +1,9 @@
|
||||
: (parseh) ( a -- n f )
|
||||
( '0': ASCII 0x30 'x': 0x78 0x7830 )
|
||||
DUP 1+ @ 0x7830 = NOT IF 0 EXIT THEN ( a 0 )
|
||||
( '0': ASCII 0x30 'x': 0x78 0x7830: 30768 )
|
||||
DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 )
|
||||
( We have "0x" prefix )
|
||||
DUP C@ ( a len )
|
||||
0 SWAP 1+ ( len+1 ) 3 DO ( a r )
|
||||
DUP 1- C@ ( a len )
|
||||
0 SWAP ( len ) 2 DO ( a r )
|
||||
OVER I + C@ ( a r c ) _ ( a r n )
|
||||
DUP 0< IF 2DROP 0 UNLOOP EXIT THEN
|
||||
SWAP 4 LSHIFT + ( a r*16+n ) LOOP
|
||||
|
8
blk/362
8
blk/362
@ -1,9 +1,9 @@
|
||||
: (parseb) ( a -- n f )
|
||||
( '0': ASCII 0x30 'b': 0x62 0x6230 )
|
||||
DUP 1+ @ 0x6230 = NOT IF 0 EXIT THEN ( a 0 )
|
||||
( '0': ASCII 0x30 'b': 0x62 0x6230: 25136 )
|
||||
DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 )
|
||||
( We have "0b" prefix )
|
||||
DUP C@ ( a len )
|
||||
0 SWAP 1+ ( len+1 ) 3 DO ( a r )
|
||||
DUP 1- C@ ( a len )
|
||||
0 SWAP ( len ) 2 DO ( a r )
|
||||
OVER I + C@ ( a r c ) _ ( a r n )
|
||||
DUP 0< IF 2DROP 0 UNLOOP EXIT THEN
|
||||
SWAP 1 LSHIFT + ( a r*2+n ) LOOP
|
||||
|
10
blk/366
10
blk/366
@ -1,13 +1,15 @@
|
||||
( Read word from C<, copy to WORDBUF, null-terminate, and
|
||||
return WORDBUF. )
|
||||
: _wb 0x0e RAM+ ;
|
||||
: _eot 0x0401 _wb ! _wb ;
|
||||
: _eot 4 _wb ! _wb ;
|
||||
: WORD
|
||||
_wb 1+ TOWORD ( a c )
|
||||
DUP EOT? IF 2DROP _eot EXIT THEN
|
||||
BEGIN
|
||||
OVER C! 1+ C< ( a c )
|
||||
OVER 0x2e RAM+ = OVER WS? OR
|
||||
( We take advantage of the fact that char MSB is
|
||||
always zero to pre-write our null-termination )
|
||||
OVER ! 1+ C< ( a c )
|
||||
OVER 0x2d ( 2e-1 for NULL ) RAM+ = OVER WS? OR
|
||||
UNTIL ( a c )
|
||||
SWAP _wb - 1- ( ws len ) _wb C!
|
||||
EOT? IF _eot ELSE _wb THEN ;
|
||||
EOT? IF _eot ELSE _wb 1+ THEN ;
|
||||
|
2
blk/371
2
blk/371
@ -1,5 +1,5 @@
|
||||
: [entry] ( w -- )
|
||||
C@+ ( w+1 len ) TUCK MOVE, ( len )
|
||||
1- C@+ ( w+1 len ) TUCK MOVE, ( len )
|
||||
( write prev value )
|
||||
H@ CURRENT @ - ,
|
||||
C, ( write size )
|
||||
|
2
blk/381
2
blk/381
@ -1,7 +1,7 @@
|
||||
: EMIT
|
||||
( 0x53==(emit) override )
|
||||
0x53 RAM+ @ ?DUP IF EXECUTE ELSE (emit) THEN ;
|
||||
: (print) C@+ ( a len ) 0 DO C@+ EMIT LOOP DROP ;
|
||||
: (print) 1- C@+ ( a len ) 0 DO C@+ EMIT LOOP DROP ;
|
||||
: BS 8 EMIT ; : LF 10 EMIT ; : CR 13 EMIT ;
|
||||
: CRLF CR LF ; : SPC 32 EMIT ;
|
||||
: NL 0x0a RAM+ @ ( NLPTR ) ?DUP IF EXECUTE ELSE CRLF THEN ;
|
||||
|
2
blk/382
2
blk/382
@ -4,7 +4,7 @@
|
||||
AGAIN ;
|
||||
: LIT"
|
||||
34 , ( litWord ) H@ 0 C, ,"
|
||||
DUP H@ -^ 1- ( a len ) SWAP C!
|
||||
DUP H@ -^ 1- ( a len ) SWAP C! 0 C,
|
||||
; IMMEDIATE
|
||||
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE
|
||||
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
|
||||
|
2
blk/392
2
blk/392
@ -1,6 +1,6 @@
|
||||
: INTERPRET
|
||||
BEGIN
|
||||
WORD DUP @ 0x0401 = ( EOT ) IF DROP EXIT THEN
|
||||
WORD DUP C@ EOT? IF DROP EXIT THEN
|
||||
FIND NOT IF (parse) ELSE EXECUTE THEN
|
||||
C<? NOT IF SPC LIT< ok (print) NL THEN
|
||||
AGAIN ;
|
||||
|
2
blk/399
2
blk/399
@ -1,4 +1,4 @@
|
||||
: LIT< WORD 34 , DUP C@ 1+ MOVE, ; IMMEDIATE
|
||||
: LIT< WORD 34 , 1- DUP C@ 1+ MOVE, 0 C, ; IMMEDIATE
|
||||
: BEGIN H@ ; IMMEDIATE
|
||||
: AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE
|
||||
: UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user