[futurebasic] Re: [FB] Signed and unsigned comparison

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2007 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sun, 13 May 2007 12:03:06 +1200
Stu Cram wrote:

>> Comparisons (>, >=, <, <=) of pointer variables in FB are always  
>> signed. Needing an unsigned '>' comparison, I found it necessary  
>> to use the clumsy function UnsignedGreaterThan() below, with its  
>> unpleasant lapse into assembler.
>> Can someone supply a more elegant method?
>
> Just a thought but untried...
> Would creating unsigned integer XREF variables
> that occupy the same memory as the pointers
> be useful here? Then compared the XREF values.

No, comparisons (of 32-bit quantities) are always unsigned in FB,  
because the compiler emits only the PPC opcode cmp (compare  
algebraic) and never emits cmpl (compare unsigned), even if the vars  
are unsigned long. That's why I resorted to assembler:
` cmpl cr0,0,^p1,^p2 ; unsigned comparison

Robert P.