[Patch, sim, moxie] change branch target offsets

Anthony Green green@moxielogic.com
Sat Sep 8 01:24:00 GMT 2012


I recently changed the encodings of branch instructions based on
feedback from the first hardware implementation.  There's a
corresponding gas change that has already been checked in.  I'm
checking this change in.

Thanks,

AG


2012-09-07  Anthony Green  <green@moxielogic.com>

	* interp.c (sim_resume): Branches are now relative to the
          address of the instruction following the branch.

diff --git a/src/sim/moxie/interp.c b/src/sim/moxie/interp.c
index f176c8a..65a0d29 100644
--- a/src/sim/moxie/interp.c
+++ b/src/sim/moxie/interp.c
@@ -268,69 +268,69 @@ void sim_resume (SIM_DESC sd, int step, int siggnal)
 		  {
 		    TRACE("beq");
 		    if (cpu.asregs.cc & CC_EQ)
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x01: /* bne */
 		  {
 		    TRACE("bne");
 		    if (! (cpu.asregs.cc & CC_EQ))
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x02: /* blt */
 		  {
 		    TRACE("blt");
 		    if (cpu.asregs.cc & CC_LT)
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }		  break;
 		case 0x03: /* bgt */
 		  {
 		    TRACE("bgt");
 		    if (cpu.asregs.cc & CC_GT)
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x04: /* bltu */
 		  {
 		    TRACE("bltu");
 		    if (cpu.asregs.cc & CC_LTU)
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x05: /* bgtu */
 		  {
 		    TRACE("bgtu");
 		    if (cpu.asregs.cc & CC_GTU)
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x06: /* bge */
 		  {
 		    TRACE("bge");
 		    if (cpu.asregs.cc & (CC_GT | CC_EQ))
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x07: /* ble */
 		  {
 		    TRACE("ble");
 		    if (cpu.asregs.cc & (CC_LT | CC_EQ))
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x08: /* bgeu */
 		  {
 		    TRACE("bgeu");
 		    if (cpu.asregs.cc & (CC_GTU | CC_EQ))
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		case 0x09: /* bleu */
 		  {
 		    TRACE("bleu");
 		    if (cpu.asregs.cc & (CC_LTU | CC_EQ))
-		      pc += INST2OFFSET(inst) - 2;
+		      pc += INST2OFFSET(inst);
 		  }
 		  break;
 		default:



More information about the Gdb-patches mailing list