aboutsummaryrefslogtreecommitdiff
path: root/sim/d10v/simops.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-12-01 06:27:02 +0000
committerAndrew Cagney <cagney@redhat.com>1997-12-01 06:27:02 +0000
commit70ee56c585016f0b3b24814af61c458e8c7def4f (patch)
tree907dccf2f6595e455b9267470438fc170dd6bbdb /sim/d10v/simops.c
parent664298e6dc699825f3cd1fe0f4f4ee5593cffd9f (diff)
downloadgdb-70ee56c585016f0b3b24814af61c458e8c7def4f.zip
gdb-70ee56c585016f0b3b24814af61c458e8c7def4f.tar.gz
gdb-70ee56c585016f0b3b24814af61c458e8c7def4f.tar.bz2
Rework sim/common/sim-alu.h to differentiate between direcct
subtraction (involves borrow) and negated addition (involves carry). Update d30v so that it uses this method. Add more tests.
Diffstat (limited to 'sim/d10v/simops.c')
-rw-r--r--sim/d10v/simops.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sim/d10v/simops.c b/sim/d10v/simops.c
index df0f826..222d2d4 100644
--- a/sim/d10v/simops.c
+++ b/sim/d10v/simops.c
@@ -1931,23 +1931,23 @@ OP_5201 ()
void
OP_4201 ()
{
- int64 tmp;
+ signed64 tmp;
int shift = SEXT3 (OP[2]);
trace_input ("rachi", OP_REG_OUTPUT, OP_ACCUM, OP_CONSTANT3);
State.F1 = State.F0;
if (shift >=0)
- tmp = SEXT44 (State.a[OP[1]]) << shift;
+ tmp = SEXT40 (State.a[OP[1]]) << shift;
else
- tmp = SEXT44 (State.a[OP[1]]) >> -shift;
+ tmp = SEXT40 (State.a[OP[1]]) >> -shift;
tmp += 0x8000;
- if (tmp > MAX32)
+ if (tmp > SEXT44 (SIGNED64 (0x0007fffffff)))
{
State.regs[OP[0]] = 0x7fff;
State.F0 = 1;
}
- else if (tmp < 0xfff80000000LL)
+ else if (tmp < SEXT44 (SIGNED64 (0xfff80000000)))
{
State.regs[OP[0]] = 0x8000;
State.F0 = 1;
@@ -2480,8 +2480,10 @@ OP_1000 ()
trace_input ("sub2w", OP_DREG, OP_DREG, OP_VOID);
a = (uint32)((State.regs[OP[0]] << 16) | State.regs[OP[0]+1]);
b = (uint32)((State.regs[OP[1]] << 16) | State.regs[OP[1]+1]);
- tmp = a-b;
- State.C = (tmp > a);
+ /* see ../common/sim-alu.h for a more extensive discussion on how to
+ compute the carry/overflow bits */
+ tmp = a - b;
+ State.C = (a < b);
State.regs[OP[0]] = (tmp >> 16) & 0xffff;
State.regs[OP[0]+1] = tmp & 0xffff;
trace_output (OP_DREG);
@@ -2577,14 +2579,17 @@ OP_17001002 ()
void
OP_1 ()
{
- uint16 tmp;
+ unsigned tmp;
if (OP[1] == 0)
OP[1] = 16;
trace_input ("subi", OP_REG, OP_CONSTANT16, OP_VOID);
- tmp = State.regs[OP[0]] - OP[1];
- State.C = (tmp > State.regs[OP[0]]);
- State.regs[OP[0]] = tmp;
+ /* see ../common/sim-alu.h for a more extensive discussion on how to
+ compute the carry/overflow bits */
+ tmp = ((unsigned)(unsigned16) State.regs[OP[0]]
+ + (unsigned)(unsigned16) ( - OP[1]));
+ State.C = (tmp >= (1 << 16));
+ State.regs[OP[0]] = tmp;
trace_output (OP_REG);
}