# cmp<kind>

## Purpose

Perform the indicated floating point or long comparison, storing 0 if the two arguments are equal, 1 if the second argument is larger, or -1 if the first argument is larger. The "bias" listed for the floating point operations indicates how NaN comparisons are treated: "Gt bias" instructions return 1 for NaN comparisons, and "lt bias" instructions return -1.

For example, to check to see if floating point a < b, then it is advisable to use cmpg-float; a result of -1 indicates that the test was true, and the other values indicate it was false either due to a valid comparison or because one or the other values was NaN.

## Details

Op & Format | Mnemonic / Syntax | Arguments
--- | --- | ---
2d..31 23x | cmpkind vAA, vBB, vCC 2d: cmpl-float (lt bias) 2e: cmpg-float (gt bias) 2f: cmpl-double (lt bias) 30: cmpg-double (gt bias) 31: cmp-long | `A:` destination register (8 bits) `B:` first source register or pair `C:` second source register or pair

## Constraints

- A, B and C must be valid register indices in the current stack frame.
- For the two -float variants, both vB and vC must be of type float.
- For the two -double variants, both vB and vC must be the lower part of a register pair holding a double value.
- For the -long variant, both both vB and vC must be the lower part of a register pair holding a long value.

## Behavior

- The values of registers vB and vC are compared. The result, which is stored in vA, is one of the following three:
  - If vB < vC, then vA'=-1.
  - If vB == vC, then vA'=0.
  - If vC > vC, then vA'=1.
- For the -float and -double variants, an addition "bias" specifies what happens if one or both of the arguments are NaN:
  - A "lt bias" results in vA'=-1.
  - A "gt bias" results in vA'=1.
- If v(A-1) is the lower half of a register pair, v(A-1)' becomes undefined.
- If v(A+1) is the upper half of a register pair, v(A+1)' becomes undefined.

## Exceptions

None.