(parsed): fix crash on parsing non-decimal staring with '-'
The address returned in the error condition would be off by one.
This commit is contained in:
parent
2d17b4e8ec
commit
d8a6456206
1
blk/354
1
blk/354
@ -7,6 +7,7 @@
|
|||||||
: MIN ( n n - n ) 2DUP > IF SWAP THEN DROP ;
|
: MIN ( n n - n ) 2DUP > IF SWAP THEN DROP ;
|
||||||
: MAX ( n n - n ) 2DUP < IF SWAP THEN DROP ;
|
: MAX ( n n - n ) 2DUP < IF SWAP THEN DROP ;
|
||||||
: NIP SWAP DROP ; : TUCK SWAP OVER ;
|
: NIP SWAP DROP ; : TUCK SWAP OVER ;
|
||||||
|
: -^ SWAP - ;
|
||||||
: 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+ ;
|
||||||
: C@- ( a -- a-1 c ) DUP C@ SWAP 1- SWAP ;
|
: C@- ( a -- a-1 c ) DUP C@ SWAP 1- SWAP ;
|
||||||
|
15
blk/357
15
blk/357
@ -1,11 +1,8 @@
|
|||||||
: _ ( a+1 len -- n f )
|
: (parsed) ( a -- n f )
|
||||||
OVER C@ ( a len c )
|
C@+ OVER C@ 0 ( a len firstchar startat )
|
||||||
'-' = IF
|
SWAP '-' = IF 1+ THEN ( a len startat )
|
||||||
1- SWAP 1+ SWAP ( a+1 len-1 ) _ 0 ROT ( f 0 n )
|
0 ROT ROT ( len ) ( startat ) DO ( a r )
|
||||||
- SWAP EXIT ( 0-n f )
|
|
||||||
THEN ( a len )
|
|
||||||
0 SWAP ( len ) 0 DO ( a r )
|
|
||||||
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
||||||
IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
||||||
NIP 1 ;
|
( negate if needed )
|
||||||
: (parsed) ( a -- n f ) C@+ ( a+1 l ) _ ;
|
SWAP C@ '-' = IF 0 -^ THEN 1 ( r 1 ) ;
|
||||||
|
1
blk/367
1
blk/367
@ -3,7 +3,6 @@
|
|||||||
DUP C@ 128 OR SWAP C! ;
|
DUP C@ 128 OR SWAP C! ;
|
||||||
: IMMED? 1- C@ 0x80 AND ;
|
: IMMED? 1- C@ 0x80 AND ;
|
||||||
: +! TUCK @ + SWAP ! ;
|
: +! TUCK @ + SWAP ! ;
|
||||||
: -^ SWAP - ;
|
|
||||||
: / /MOD NIP ;
|
: / /MOD NIP ;
|
||||||
: MOD /MOD DROP ;
|
: MOD /MOD DROP ;
|
||||||
: ALLOT HERE +! ;
|
: ALLOT HERE +! ;
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user