COP1: Difference between revisions

1,636 bytes added ,  1 year ago
No edit summary
Line 192:
 
== Comparisons ==
The COP1 in total has 16 single compare instructions with some pretty confusing names (and another 16 for doubles). When implementing them in an emulator, it's best to ignore their names and just look at the bits of the instruction:
The COP1 has plenty of compare instructions
 
* Unordered (Bit 0): Comparison is considered true if one or both of the operands is NAN
* Equal (Bit 1): Comparison is considered true if both operands are equal (note that 0 is equal to -0, but NAN is always different from another NAN)
* Smaller (Bit 2): Comparison is considered true if the first operand is smaller than the second
* SignalOnSNAN (Bit 3): If either operand is sNAN, this will signal Invalid Operation.
 
If multiple bits are set, the conditions are ORed together: For example, UEQ is considered true if the two operands are equal or unordered.
 
{| class="wikitable"
|+ Compare encoding
|-
! SignalOnSNAN (Bit 3) !! Smaller (Bit 2) || Equal (Bit 1) || Unordered (Bit 0) || Name || Description
|-
| 0 || 0 || 0 || 0 || F || false
|-
| 0 || 0 || 0 || 1 || UN || Result = unordered(arg1, arg2)
|-
| 0 || 0 || 1 || 0 || EQ || Result = arg1 == arg2
|-
| 0 || 0 || 1 || 1 || UEQ || Result = unordered(arg1, arg2) || (arg1 == arg2)
|-
| 0 || 1 || 0 || 0 || OLT || Result = arg1 < arg2
|-
| 0 || 1 || 0 || 1 || ULT || Result = unordered(arg1, arg2) || (arg1 < arg2)
|-
| 0 || 1 || 1 || 0 || OLE || Result = arg1 <= arg2
|-
| 0 || 1 || 1 || 1 || ULE || Result = unordered(arg1, arg2) || (arg1 <= arg2)
|-
| 1 || 0 || 0 || 0 || SF
|-
| 1 || 0 || 0 || 1 || NGLE
|-
| 1 || 0 || 1 || 0 || SEQ
|-
| 1 || 0 || 1 || 1 || NGL
|-
| 1 || 1 || 0 || 0 || LT
|-
| 1 || 1 || 0 || 1 || NGE
|-
| 1 || 1 || 1 || 0 || LE
|-
| 1 || 1 || 1 || 1 || NGT
|-|}
14

edits