From 36aef94270988051fc9186dfaf4d1e4493e02086 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 27 Mar 2011 04:03:05 +0000 Subject: [PATCH] sim: bfin: handle saturation with RND12 sub insns The current handling of the subtraction insn with the RND12 modifier works when saturation isn't involved. So add handling for this edge case to match the hardware. Signed-off-by: Robin Getz Signed-off-by: Mike Frysinger --- sim/bfin/ChangeLog | 5 +++++ sim/bfin/bfin-sim.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index 008edf0f9d..a28da1a3f6 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,3 +1,8 @@ +2011-03-26 Robin Getz + + * bfin-sim.c (decode_dsp32alu_0): Set result to 0x7FFFFFFF when + the result was 0x80000000 for RND12 subtraction. + 2011-03-26 Robin Getz * bfin-sim.c (decode_dsp32alu_0): Set VS when V is set. diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c index 7e747ff1e3..1555dc2c3f 100644 --- a/sim/bfin/bfin-sim.c +++ b/sim/bfin/bfin-sim.c @@ -4009,7 +4009,12 @@ decode_dsp32alu_0 (SIM_CPU *cpu, bu16 iw0, bu16 iw1) /* If subtract, just invert and add one. */ if (aop & 0x1) - val1 = ~val1 + 1; + { + if (val1 == 0x80000000) + val1 = 0x7FFFFFFF; + else + val1 = ~val1 + 1; + } /* Get the sign bits, since we need them later. */ sBit1 = !!(val0 & 0x80000000); -- 2.34.1