From 2169d80370695f8f537ac77ebc11dec6558873c1 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Sun, 5 Jan 2020 17:56:38 +0100 Subject: [PATCH] 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. --- data/languages/xtensaInstructions.sinc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/languages/xtensaInstructions.sinc b/data/languages/xtensaInstructions.sinc index 017fe88..e3e4766 100644 --- a/data/languages/xtensaInstructions.sinc +++ b/data/languages/xtensaInstructions.sinc @@ -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.