diff options
-rw-r--r-- | sim/testsuite/v850/allinsns.exp | 2 | ||||
-rw-r--r-- | sim/testsuite/v850/bins.cgs | 12 | ||||
-rw-r--r-- | sim/v850/simops.c | 9 |
3 files changed, 21 insertions, 2 deletions
diff --git a/sim/testsuite/v850/allinsns.exp b/sim/testsuite/v850/allinsns.exp index 4cc461c..ee22a5d 100644 --- a/sim/testsuite/v850/allinsns.exp +++ b/sim/testsuite/v850/allinsns.exp @@ -5,7 +5,7 @@ sim_init # All machines. # Should add more cpus if the testsuite adds coverage for their insns, but # at the core level, there's no deviation beyond these two. -set all_machs "v850e v850" +set all_machs "v850e3v5 v850e v850" # gas doesn't support any '=' option for v850. set cpu_option_sep "" diff --git a/sim/testsuite/v850/bins.cgs b/sim/testsuite/v850/bins.cgs new file mode 100644 index 0000000..dedc5ce --- /dev/null +++ b/sim/testsuite/v850/bins.cgs @@ -0,0 +1,12 @@ +# v850 bins +# mach: v850e3v5 +# as: -mv850e3v5 + + .include "testutils.inc" + + seti 0x7fff, r10 + seti 0x0, r11 + bins r10, 0, 32, r11 + reg r11, 0x7fff + + pass diff --git a/sim/v850/simops.c b/sim/v850/simops.c index d264057..e9a5d48 100644 --- a/sim/v850/simops.c +++ b/sim/v850/simops.c @@ -3267,7 +3267,14 @@ v850_bins (SIM_DESC sd, unsigned int source, unsigned int lsb, unsigned int msb, pos = lsb; width = (msb - lsb) + 1; - mask = ~ (-(1 << width)); + /* A width of 32 exhibits undefined behavior on the shift. The easiest + way to make this code safe is to just avoid that case and set the mask + to the right value. */ + if (width >= 32) + mask = 0xffffffff; + else + mask = ~ (-(1 << width)); + source &= mask; mask <<= pos; result = (* dest) & ~ mask; |