Thanks for pointing that out. I never used FIG-Forth exactly, but much of what I started with came from FIG-Forth. My U< says (after forming the header):
Code:
LDA 3,X
CMP 1,X
BNE 1$
LDA 2,X
CMP 0,X
1$: BCS 2$
JMP POP_TRUE ; Remove one stack cell, replace the other input with -1.
2$: JMP POP_FALSE ; Remove one stack cell, replace the other input with 0.
I don't remember if that's what it came with or if it's my own fix.
What I have in my '816 Forth is:
Code:
LDA 2,X
CMP 0,X
BCC ugtcc ; like BCClong to POP_TRUE.
JMP POP_FALSE
I had a problem early on in the 6502 Forth I was working with which defined
D< as:
Code:
: D< D- D0< ;
My first encounter with the problem occurred with the numbers -70007FFF and FFF8002. D< said the negative number was
not less than the positive number because -70007FFF (or 8FFF8001) minus FFF8002 gives 7FFFFFFF, which is positive. However, if we add 1 to the first number making it -70007FFE, the D- gives an answer of 80000000, and D< correctly says that yes, the first number is indeed less than the second. My own replacement (as a secondary, since I didn't use it often enough to warrant a primitive at the time), was:
Code:
: D< ROT
2DUP =
IF 2DROP U< EXIT THEN
> -ROT 2DROP ;
What I have in my '816 Forth is:
Code:
LDA 6,X
CMP 2,X
LDA 4,X
SBC 0,X
dlt2: bvc dlt1 ; If the resulting sign is wrong,
EOR #$8000 ; invert it.
dlt1: BPL dult1 ; Now if N is set, d2 < d1 (or
dlt3: JMP POP3_TRUE ; d1 < d2 if branched here from D> ).
BPL dult1 above is like a BPLlong to POP3_FALSE.
With a quick look, I did not find D< in my FIG-Forth book, but be careful.
Hopefully I copied all the code correctly. Although my '816 Forth was never finished to the point of being ready to publish, I am not aware of any bugs in it, and Wally Daniels used it for awhile in his work in the Pratt & Whitney turbine-engine plant in Nova Scotia.