[PicForth] Re: More <0 strangeness
Samuel Tardieu
sam at rfc1149.net
Wed Nov 24 09:52:39 CET 2004
>>>>> "Alex" == Alex Holden <alex at linuxhacker.org> writes:
Alex> This time I appear to have found a weird optimization bug with
Alex> the 0< word.
Could you try the following patch? (or get it from my repository)
Wed Nov 24 09:47:14 CET 2004 Samuel Tardieu <sam at rfc1149.net>
* Fix 0 < case
--- picforth-1-old/picforth.fs 2004-11-24 09:50:24.000000000 +0100
+++ picforth-1-new-4/picforth.fs 2004-11-24 09:47:34.000000000 +0100
@@ -1733,7 +1733,11 @@
: <
const? if
- kill-const negate popw addlw pushw carry-clr?
+ kill-const ?dup if
+ negate popw addlw pushw carry-clr?
+ else
+ meta> 0<
+ then
else
meta> - carry-clr?
then
The reason was that to implement "ACONSTANT <", PicForth was adding
the opposite value of ACONSTANT and checking the carry bit. Of course,
adding minus zero didn't set the carry bit.
"0<" on the other hand was told to properly look at the sign bit. Now,
it is called when "0 <" is used.
Sam
--
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/sam
More information about the PicForth
mailing list