Numeric comparisons

Alan Covington arc at myriasb.UUCP
Fri Sep 27 09:06:45 AEST 1985


Chris Torek writes
>   I offer another example.  Take a 32 bit machine---the Vax---both for
>   simplicity and because the Vax does compares via subtraction.  But I
>   will use a byte instruction:

The VAX cmp and sub instructions set the condition codes differently.
Thus, the cmp is not just a "subtract" with the result thrown away.
An easy example is comparing 0x80000000 and 1 results in the N bit
of the condition codes being set, whereas subtracting 1 from 0x80000000
results in the overflow bit being set.  The VAX may use a subtract as
part of the cmp instruction, but it doesn't do signed comparison as
Chris claims.
>    A signed comparison is a subtract with the result
>    thrown away.

		Alan Covington  ...!alberta!myrias!arc



More information about the Comp.lang.c mailing list