Fix UTRUNC.S

There is no unsigned trunc() pcodeop, so scale and truncate with double
precision and check for over-/underflow separately. The over- and
underflow values are taken from the documentation.
This commit is contained in:
Sebastian Schmidt
2020-01-05 17:56:38 +01:00
parent 83112e48da
commit 2169d80370

View File

@@ -1243,10 +1243,14 @@ macro extract_bit(val, bit, result) {
br = nan(fs) || nan(ft);
}
# UTRUNC.S - Truncate Single to Fixed Unsigned, pg. 555. FIXME: difference to trunc.s?
# UTRUNC.S - Truncate Single to Fixed Unsigned, pg. 555.
:utrunc.s ar, fs, u4_4.7 is op2 = 0b1110 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {
local scale:4 = int2float(1:2 << u4_4.7:2);
ar = trunc(fs f* scale);
local tmp:8 = trunc(fs f* scale);
local posof = nan(fs) || (tmp >> 16) != 0;
local negof = tmp s< 0;
local noof = !posof && !negof;
ar = zext(posof)*0xffffffff + zext(negof)*0x80000000 + zext(noof)*tmp:4;
}
# WAITI - Wait Interrupt, pg. 556.