v850 simulator patch for trap instruction
Jim Wilson
wilson@redhat.com
Thu Sep 26 16:26:00 GMT 2002
The v850 architecture manual says that a trap instruction sets the pc to
0x40 or 0x50 depending on the trap code. The v850 simulator is setting the
PC to a value 4 bytes too small.
Here is a simple example.
.global _main
.text
_main:
trap 0x1
.offset 0x40
halt
If I assemble this testcase, and run it on the simuator with --trace, I get
insn: 0x000000 --- _main trap 1 - trap
insn: 0x00003c --- _main nop - nop
insn: 0x00003e --- _main nop - nop
insn: 0x000040 --- _main halt - halt
program stopped with signal 5.
This shows that the simulator branches to the wrong address, since it
executed two nops before reaching the trap handler address.
This patch fixes the problem. I have tested this with a gdb make check
and there are no regressions.
2002-09-26 Jim Wilson <wilson@redhat.com>
* simops (OP_10007E0): Don't subtract 4 from PC.
Index: simops.c
===================================================================
RCS file: /cvs/src/src/sim/v850/simops.c,v
retrieving revision 1.3
diff -p -r1.3 simops.c
*** simops.c 29 Aug 2002 16:59:20 -0000 1.3
--- simops.c 26 Sep 2002 23:17:47 -0000
*************** OP_10007E0 ()
*** 1880,1886 ****
ECR |= 0x40 + OP[0];
/* Flag that we are now doing exception processing. */
PSW |= PSW_EP | PSW_ID;
! PC = ((OP[0] < 0x10) ? 0x40 : 0x50) - 4;
return 0;
}
--- 1880,1886 ----
ECR |= 0x40 + OP[0];
/* Flag that we are now doing exception processing. */
PSW |= PSW_EP | PSW_ID;
! PC = (OP[0] < 0x10) ? 0x40 : 0x50;
return 0;
}
More information about the Gdb-patches
mailing list