VU0 flags: O for an overflow or a result at the largest magnitude (0x7fffffff), not for every exponent-255 result (stage-level3 #15807299 and match4p #76722184: mathfDotProduct in BuildRadarStuff, 0xfffffffe kept by a sum, status without OS; #15818358 and match1p capture #670: 0xffffffff kept, OS); the 9,232 capture samples still match

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Thomas MartinandClaude Opus 5.5 committed 2026-11-04 21:05:08 +01:00
1 parent 79fb362f37
commit def8230608
2 files changed
+10 -5

No files matched your search

+3 -2
View File
@@ -266,8 +266,9 @@ Register moves:
**Flags** (Q11). Every upper FMAC instruction (add, sub, mul, madd, msub and their bc/q/i/A forms, opmula, opmsub)
sets the MAC flags (control register 17) from its result, field by field (x = bit 3 ... w = bit 0 of each nibble):
Z (bits 0-3) the result is +/-0, S (4-7) its sign bit, U (8-11) it underflowed to zero, O (12-15) it overflowed or its
exponent is 255; fields outside dest are 0. A result below the smallest normal (a sum that cancels, a product of a tiny
Z (bits 0-3) the result is +/-0, S (4-7) its sign bit, U (8-11) it underflowed to zero, O (12-15) it overflowed or it
is the largest magnitude 0x7fffffff (phase 4 M5: 0xffffffff + 1.69 flags O, match1p #670 and stage-level3 #15818358;
0xfffffffe + 1.69 does not, stage-level3 #15807299: other exponent-255 results are ordinary numbers); fields outside dest are 0. A result below the smallest normal (a sum that cancels, a product of a tiny
factor) is zero without U: the reference never sets U or its sticky bit in TMB's runs (phase 4, match1p #41542199:
vu0MulMatrix3x3's first mul, a z product underflowing, status 0x2c2 where U would make it 0x3c2; the 9,232 capture
samples still match). The status flag (register 16) gets Z, S, U, O (bits 0-3) as the OR of the
+7 -3
View File
@@ -57,8 +57,8 @@ namespace bozo::vu0
// ---- Flags (Q11) ----
// The MAC flags of an FMAC instruction's result: for each field (x = bit 3 ... w = bit 0 of each nibble) Z (bits
// 0-3: the result is +/-0), S (4-7: its sign bit), U (8-11: it underflowed to 0), O (12-15: it overflowed, or its
// exponent is 255, beyond IEEE single's range); fields outside dest are 0. The status flag's Z, S, U, O (bits 0-3)
// 0-3: the result is +/-0), S (4-7: its sign bit), U (8-11: it underflowed to 0), O (12-15: it overflowed, or it
// is the largest magnitude, 0x7fffffff); fields outside dest are 0. The status flag's Z, S, U, O (bits 0-3)
// are the OR of the MAC's, and its sticky copies (bits 6-9) accumulate them; I, D (4, 5) and their sticky bits
// (10, 11) are the divider's. All as the reference captures show them (r5900.md Q11).
inline void setFlags(R5900Context *ctx, uint32_t dest, const uint32_t r[4], const uint32_t fl[4])
@@ -74,7 +74,11 @@ namespace bozo::vu0
mac |= 1u << (bit + 4);
if (fl[i] & ps2f::kFlagU)
mac |= 1u << (bit + 8);
if ((fl[i] & ps2f::kFlagO) || ps2f::expOf(r[i]) == 255)
// O: an overflow, or a result at the largest magnitude (the saturated value): 0xffffffff plus a small
// number flags it (match1p capture #670, 0x1335c8: status 0x2c0; stage-level3 #15818358), 0xfffffffe
// plus a small number or times 1.0 does not (stage-level3 #15807299, match4p #76722184:
// mathfDotProduct in BuildRadarStuff, status 0xc2 / 0xc0). Other exponent-255 results are ordinary.
if ((fl[i] & ps2f::kFlagO) || (r[i] & ps2f::kMax) == ps2f::kMax)
mac |= 1u << (bit + 12);
}
ctx->vu0_mac = mac;