diff --git a/blk/056 b/blk/056 index d2bc570..d3db076 100644 --- a/blk/056 +++ b/blk/056 @@ -1,11 +1,13 @@ Logic -= n1 n2 -- f Push true if n1 == n2 -< n1 n2 -- f Push true if n1 < n2 -> n1 n2 -- f Push true if n1 > n2 -CMP n1 n2 -- n Compare n1 and n2 and set n to -1, 0, or 1. += n1 n2 -- f Push true if n1 == n2 +< n1 n2 -- f Push true if n1 < n2 +> n1 n2 -- f Push true if n1 > n2 +>< n l h -- f Push true if l < n < h +=><= n l h -- f Push true if l <= n <= h +CMP n1 n2 -- n Compare n1 and n2 and set n to -1, 0, or 1. n=0: a1=a2. n=1: a1>a2. n=-1: a1= < NOT ; : <= > NOT ; : 0>= 0< NOT ; - +( n l h -- f ) +: >< 2 PICK > ( n l f ) ROT ROT > AND ; +: =><= 2 PICK >= ( n l f ) ROT ROT >= AND ; ( a -- a+1 c ) : C@+ DUP C@ SWAP 1+ SWAP ; ( c a -- a+1 ) diff --git a/blk/395 b/blk/395 index 6223ae9..00037e1 100644 --- a/blk/395 +++ b/blk/395 @@ -5,10 +5,9 @@ : _pdacc DUP 0x21 < IF DROP 1 EXIT THEN ( parse char ) - '0' - ( if bad, return "r -1" ) - DUP 0< IF DROP -1 EXIT THEN ( bad ) - DUP 9 > IF DROP -1 EXIT THEN ( bad ) + '0' - + DUP 10 < NOT IF DROP -1 EXIT THEN ( good, add to running result ) SWAP 10 * + ( r*10+n ) 0 ( good ) diff --git a/blk/399 b/blk/399 index bac471c..1b5d0e8 100644 --- a/blk/399 +++ b/blk/399 @@ -1,14 +1,8 @@ ( returns negative value on error ) : _ ( c -- n ) - ( '0' is ASCII 48 ) - 48 - - DUP 0< ( bad ) OVER 10 < ( good ) OR IF EXIT THEN - ( 'a' is ASCII 97. 59 = 97 - 48 ) - 49 - - DUP 0< IF EXIT THEN ( bad ) - DUP 6 < IF 10 + EXIT THEN ( good ) - ( bad ) - 255 - + DUP '0' '9' =><= IF '0' - EXIT THEN + DUP 'a' 'f' =><= IF 0x57 ( 'a' - 10 ) - EXIT THEN + DROP -1 ( bad ) ; diff --git a/blk/401 b/blk/401 index eb50ae5..9cee536 100644 --- a/blk/401 +++ b/blk/401 @@ -1,10 +1,7 @@ ( returns negative value on error ) : _ ( c -- n ) - ( '0' is ASCII 48 ) - 48 - - DUP 0< ( bad ) OVER 2 < ( good ) OR IF EXIT THEN - ( bad ) - 255 - + DUP '0' '1' =><= IF '0' - EXIT THEN + DROP -1 ( bad ) ; diff --git a/blk/444 b/blk/444 index 57fde9a..da6b73e 100644 --- a/blk/444 +++ b/blk/444 @@ -8,7 +8,7 @@ DROP 8 0 DO C@+ - DUP 0x20 < OVER 0x7e > OR + DUP 0x20 0x7e =><= NOT IF DROP '.' THEN EMIT LOOP diff --git a/emul/forth.bin b/emul/forth.bin index bbe4158..c93de26 100644 Binary files a/emul/forth.bin and b/emul/forth.bin differ