COP1: Difference between revisions

1,486 bytes added ,  1 year ago
no edit summary
No edit summary
Line 16:
| Single || S || 32 bit float
|-
| Double || D || 64 bit doublefloat
|-
| Word || W || 32 bit integer
Line 192:
 
== Comparisons ==
The COP1 in total has 16 single compare instructions with some pretty confusing names (and another 16 for doubles). WhenThe implementing16 theminstructions inare anall emulator,possible it'scombinations bestof tothe ignorefollowing their names and just look at the4 bits of the instruction:
 
* 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)
Line 239 ⟶ 238:
|-
| 1 || 1 || 1 || 1 || NGT || Result = unordered(arg1, arg2) OR (arg1 <= arg2) || IsNAN(arg1) OR isNAN(arg2) OR isSubnormal(arg1) OR isSubnormal(arg2)
|-|}
 
== Full Mode vs Half Mode ==
The COP1 can run in one of two modes, which is controlled via COP0.Status Bit 26. In "Full Mode", 32 bit registers that are each 64 bits wide are available. In "Half Mode", only the 16 even registers are supposed to be used; using even numbered registers is considered undefined behavior.
 
Older software usually ran in "Half Mode". A reason for that could be that context switches (for multiple threads) can be performed more cheaply, as only 16 FPU registers need to be stored.
 
When using "Half Mode" it is important to not use any FPU registers with odd indices. For compiled code this has to be configured accordingly ("+nooddspreg" in clang).
 
''The remainder of this section documents undefined behavior. Skip this unless you are an emulator developer who cares about accuracy a little bit too much.''
 
Odd numbered registers (while in "Half Mode") behave differently, which is summarized in the following table:
 
{| class="wikitable"
|+ Illegal register indexing in "Half Mode" (normally undocumented behavior - do not use)
|-
! 64 bit Register Index || MFC1/MTC1/LWC1/LDC1 || fs (32 bit) || fd (32 bit), ft (32 bit) or any 64 bit
|-
| 0 || 1 (high 32 bits) / 0 (low 32 bits) || 0 (low 32 bits) || 0 or 1
|-
| 1 || unused || 1 (low 32 bits) || unused
|-
| 2 || 3 (high 32 bits) / 2 (low 32 bits) || 2 (low 32 bits) || 3 or 2
|-
| 3 || unused || 3 (low 32 bits) || unused
|-
| 4 || 5 (high 32 bits) / 4 (low 32 bits) || 4 (low 32 bits) || 5 or 4
|-
| 5 || unused || 5 (low 32 bits) || unused
|}
14

edits