This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] sim/h8300/compile.c: Fix the handling of extu.w.


Hi,

Attached is a patch to fix the handling of extu.w.

Giving "extu.w e0" to the H8 simulator causes it to segfault because
the simulation of "extu.w e0" attempts to access a 8-bit wide register
that does not exist.  The patch fixes the problem by accessing a
16-bit wide register and then extending its lower half appropriately.

OK to apply?

Kazu Hirata

2002-12-27  Kazu Hirata  <kazu@cs.umass.edu>

	* compile.c (sim_resume): Fix the handling of exts.w and
	extu.w.

Index: compile.c
===================================================================
RCS file: /cvs/src/src/sim/h8300/compile.c,v
retrieving revision 1.18
diff -u -r1.18 compile.c
--- compile.c	26 Dec 2002 05:44:46 -0000	1.18
+++ compile.c	27 Dec 2002 17:44:01 -0000
@@ -1622,7 +1622,7 @@
 	    goto next;
 	  }
 	case O (O_EXTS, SW):
-	  rd = GET_B_REG (code->src.reg + 8) & 0xff; /* Yes, src, not dst.  */
+	  rd = GET_W_REG (code->src.reg) & 0xff; /* Yes, src, not dst.  */
 	  ea = rd & 0x80 ? -256 : 0;
 	  res = rd + ea;
 	  goto log16;
@@ -1632,7 +1632,7 @@
 	  res = rd + ea;
 	  goto log32;
 	case O (O_EXTU, SW):
-	  rd = GET_B_REG (code->src.reg + 8) & 0xff;
+	  rd = GET_W_REG (code->src.reg) & 0xff;
 	  ea = 0;
 	  res = rd + ea;
 	  goto log16;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]