static bu32
decode_macfunc (SIM_CPU *cpu, int which, int op, int h0, int h1, int src0,
- int src1, int mmod, int MM, int fullword, bu32 *overflow)
+ int src1, int mmod, int MM, int fullword, bu32 *overflow,
+ bu32 *neg)
{
bu64 acc;
- bu32 sat = 0, tsat;
+ bu32 sat = 0, tsat, ret;
/* Sign extend accumulator if necessary, otherwise unsigned. */
if (mmod == 0 || mmod == M_T || mmod == M_IS || mmod == M_ISS2
default:
illegal_instruction (cpu);
}
+
+ if (acc & 0x8000000000ull)
+ *neg = 1;
}
STORE (AXREG (which), (acc >> 32) & 0xff);
if (sat)
STORE (ASTATREG (avs[which]), sat);
- return extract_mult (cpu, acc, mmod, MM, fullword, overflow);
+ ret = extract_mult (cpu, acc, mmod, MM, fullword, overflow);
+
+ if (!fullword)
+ {
+ if (ret & 0x8000)
+ *neg = 1;
+ }
+ else
+ {
+ if (ret & 0x80000000)
+ *neg = 1;
+ }
+
+ return ret;
}
bu32
int h01 = ((iw1 >> DSP32Mac_h01_bits) & DSP32Mac_h01_mask);
bu32 res = DREG (dst);
- bu32 v_i = 0, zero = 0;
+ bu32 v_i = 0, zero = 0, n_1 = 0, n_0 = 0;
static const char * const ops[] = { "=", "+=", "-=" };
char _buf[128], *buf = _buf;
if (w1 == 1 || op1 != 3)
{
bu32 res1 = decode_macfunc (cpu, 1, op1, h01, h11, src0,
- src1, mmod, MM, P, &v_i);
+ src1, mmod, MM, P, &v_i, &n_1);
if (w1)
buf += sprintf (buf, P ? "R%i" : "R%i.H", dst + P);
if (w0 == 1 || op0 != 3)
{
bu32 res0 = decode_macfunc (cpu, 0, op0, h00, h10, src0,
- src1, mmod, 0, P, &v_i);
+ src1, mmod, 0, P, &v_i, &n_0);
if (w0)
buf += sprintf (buf, P ? "R%i" : "R%i.L", dst);
if (v_i)
SET_ASTATREG (vs, v_i);
}
- if (op0 == 3 || op1 == 3)
- SET_ASTATREG (az, zero);
+
+ if ((w0 == 1 && op0 == 3) || (w1 == 1 && op1 == 3))
+ {
+ SET_ASTATREG (az, zero);
+ if (!(w0 == 1 && op0 == 3))
+ n_0 = 0;
+ if (!(w1 == 1 && op1 == 3))
+ n_1 = 0;
+ SET_ASTATREG (an, n_1 | n_0);
+ }
}
static void