This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

RE: [PATCH] Fix for ldm/stm instructions in H8S


Hi Nick,

I have modified patch for H8S and H8SX targets. Also I have created patches 
for multiples.s and h8300.exp in gas/h8300 testsuite. This was tested with 
binutils-031111 testsuite and found okay.

Regards,
Asgari Jinia

-------------------- Start of gas patch ---------------------------------
bfd change log:

2003-11-20  Asgari Jinia  <asgarij@kpitcummins.com>

	* config/tc-h8300.c (md_assemble): Check operands validity for
	ldm/stm.
	(get_operand): Check register pair's validity as per technical
	note TN-H8*-193A/E from Renesas for H8s and for H8Sx manual.

--- config/tc-h8300.c.old	2003-11-21 18:04:38.000000000 +0530
+++ config/tc-h8300.c	2003-11-21 18:06:32.000000000 +0530
@@ -622,14 +622,18 @@ get_operand (ptr, op, direction)
       low = src[2] - '0';
       high = src[6] - '0';
 
-      if (high == low)
-	as_bad (_("Invalid register list for ldm/stm\n"));
-
-      if (high < low)
+       /* Check register pair's validity as per tech note TN-H8*-193A/E
+         from Renesas for H8S and H8SX hardware manual.  */
+      if (!(low == 0 && (high == 1 || high == 2 || high == 3))
+          && !(low == 1 && (high == 2 || high == 3 || high == 4) && SXmode)
+          && !(low == 2 && (high == 3 || ((high == 4 || high == 5) && SXmode)))
+          && !(low == 3 && (high == 4 || high == 5 || high == 6) && SXmode)
+          && !(low == 4 && (high == 5 || high == 6))
+          && !(low == 5 && (high == 6 || high == 7) && SXmode)
+          && !(low == 6 && high == 7 && SXmode))
+        {
 	as_bad (_("Invalid register list for ldm/stm\n"));
-
-      if (high - low > 3)
-	as_bad (_("Invalid register list for ldm/stm)\n"));
+        }
 
       /* Even sicker.  We encode two registers into op->reg.  One
 	 for the low register to save, the other for the high
@@ -1965,6 +1969,32 @@ md_assemble (str)
   *op_end = c;
   prev_instruction = instruction;
 
+  /* Now we have operands from instruction.  Let's check them out for
+     ldm and stm.  */
+  if (OP_KIND (instruction->opcode->how) == O_LDM)
+    {
+      /* The first operand must be @er7+, and the second operand must
+          be a register pair.  */
+      if ((operand[0].mode != RSINC)
+           || (operand[0].reg != 7)
+           || ((operand[1].reg & 0x80000000) == 0))
+        {
+          as_bad (_("invalid operand in ldm"));
+        }
+    }
+
+  if (OP_KIND (instruction->opcode->how) == O_STM)
+    {
+      /* The first operand must be a register pair, and the second
+          operand must be @-er7.  */
+      if (((operand[0].reg & 0x80000000) == 0)
+            || (operand[1].mode != RDDEC)
+            || (operand[1].reg != 7))
+        {
+          as_bad (_("invalid operand in stm"));
+        }
+    }
+
   size = SN;
   if (dot)
     {

-------------------- End of gas patch -----------------------------------
--------------------- Start of testsuite patch --------------------------
gas testsuit change log:

2003-11-20  Asgari Jinia  <asgarij@kpitcummins.com>

	* gas/h8300/multiples.s : added instructions for H8s.


--- gas/h8300/multiples.s.old	1999-05-03 12:58:50.000000000 +0530
+++ gas/h8300/multiples.s	2003-11-20 17:27:25.000000000 +0530
@@ -7,4 +7,11 @@ h8300s_multiple:
 	stm.l er0-er1,@-sp
 	stm.l er0-er2,@-sp
 	stm.l er0-er3,@-sp
+        ldm.l @sp+,er2-er3
+        stm.l er2-er3,@-sp
+        ldm.l @sp+,er4-er5
+        ldm.l @sp+,er4-er6
+        stm.l er4-er5,@-sp
+        stm.l er4-er6,@-sp
+
 

2003-11-20  Asgari Jinia  <asgarij@kpitcummins.com>

	* gas/h8300/h8300.exp (do_h8300s_multiple) : added more test conditions for instructions for H8s.


--- gas/h8300/h8300.exp.old	2003-06-24 19:24:50.000000000 +0530
+++ gas/h8300/h8300.exp	2003-11-20 17:31:06.000000000 +0530
@@ -2070,6 +2070,13 @@ proc do_h8300s_multiple {} {
 	    -re " +\[0-9\]+ 000c 01106DF0\[^\n\]*\n"   { set x [expr $x+1] }
 	    -re " +\[0-9\]+ 0010 01206DF0\[^\n\]*\n"   { set x [expr $x+1] }
 	    -re " +\[0-9\]+ 0014 01306DF0\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 0018 01106D73\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 001c 01106DF2\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 0020 01106D75\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 0024 01206D76\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 0028 01106DF4\[^\n\]*\n"   { set x [expr $x+1] }
+            -re " +\[0-9\]+ 002c 01206DF4\[^\n\]*\n"   { set x [expr $x+1] }
+
 	    eof					{ break }
 	}
     }
@@ -2079,7 +2086,7 @@ proc do_h8300s_multiple {} {
     gas_finish
 
     # Did we find what we were looking for?  If not, flunk it.
-    if [expr $x == 6] then { pass $testname } else { fail $testname }
+    if [expr $x == 12] then { pass $testname } else { fail $testname }
 }
 
 proc do_h8300h_mov32bug {} {


---------------------- End of testsuit patch--------------------------

-----Original Message-----
From: Nick Clifton [mailto:nickc@redhat.com]
Sent: Wednesday, November 12, 2003 12:39 AM
To: Asgari J. Jinia
Cc: kazu@cs.umass.edu; binutils@sources.redhat.com
Subject: Re: [PATCH] Fix for ldm/stm instructions in H8S



Applying this patch breaks lots of tests in the h8300 gas testsuite.
Would it be possible for you to investigate this and see whether the
patch or the testcases need to be fixed ?

Cheers
        Nick
        


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