This is the mail archive of the binutils@sourceware.org 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]

Commit: V850: Fix disassembly of reg+offset addressing


Hi Guys,

  I am applying the patch below to fix a small problem with the V850
  port.  In some cases the disassembler would fail to print a closing
  square brace, so that, for example:

    st.w  lp, 156[sp]

  would be displayed as:

    st.w  lp,156[sp

  The attached patch fixes the problem and adds a small testcase to make
  sure that the problem does not return.

Cheers
  Nick

opcodes/ChangeLog
2011-04-13  Nick Clifton  <nickc@redhat.com>

	* v850-dis.c (disassemble): Always print a closing square brace if
	an opening square brace was printed.

gas/testsuite/ChangeLog
2011-04-13  Nick Clifton  <nickc@redhat.com>

	* gas/v850/v850e1.s: Add a insn using reg+offset addressing.
	* gas/v850/v850e1.d: Add expected disassembly.

Index: opcodes/v850-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/v850-dis.c,v
retrieving revision 1.12
diff -u -3 -p -r1.12 v850-dis.c
--- opcodes/v850-dis.c	23 Jul 2010 14:52:54 -0000	1.12
+++ opcodes/v850-dis.c	13 Apr 2011 13:11:59 -0000
@@ -283,6 +283,7 @@ disassemble (bfd_vma memaddr, struct dis
 	       *opindex_ptr != 0;
 	       opindex_ptr++, opnum++)
 	    {
+	      bfd_boolean square = FALSE;
 	      long value;
 	      int flag;
 	      char *prefix;
@@ -323,11 +324,17 @@ disassemble (bfd_vma memaddr, struct dis
 		}
 
 	      if (opnum == 1 && opnum == memop)
-		info->fprintf_func (info->stream, "%s[", prefix);
+		{
+		  info->fprintf_func (info->stream, "%s[", prefix);
+		  square = TRUE;
+		}
 	      else if (opnum > 1
 		       && (v850_operands[*(opindex_ptr - 1)].flags & V850_OPERAND_DISP) != 0
 		       && opnum == memop)
-		info->fprintf_func (info->stream, "%s[", prefix);
+		{
+		  info->fprintf_func (info->stream, "%s[", prefix);
+		  square = TRUE;
+		}
 	      else if (opnum > 1)
 		info->fprintf_func (info->stream, ", %s", prefix);
 
@@ -431,7 +438,7 @@ disassemble (bfd_vma memaddr, struct dis
 		  break;
 		}
 
-	      if (opnum == 2 && opnum == memop)
+	      if (square)
 		(*info->fprintf_func) (info->stream, "]");
 	    }
 
Index: gas/testsuite/gas/v850/v850e1.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/v850/v850e1.d,v
retrieving revision 1.4
diff -u -3 -p -r1.4 v850e1.d
--- gas/testsuite/gas/v850/v850e1.d	23 Jul 2010 14:52:51 -0000	1.4
+++ gas/testsuite/gas/v850/v850e1.d	13 Apr 2011 13:11:59 -0000
@@ -42,3 +42,4 @@ Disassembly of section .text:
 0x0+76 ff 07 e6 00 [ 	]*tst1	r0, lp
 0x0+7a 83 00  [ 	]*zxb	sp
 0x0+7c c4 00  [ 	]*zxh	gp
+0x0+7e 63 ff 9d 00[ 	]*st.w	lp, 156\[sp\]
Index: gas/testsuite/gas/v850/v850e1.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/v850/v850e1.s,v
retrieving revision 1.1
diff -u -3 -p -r1.1 v850e1.s
--- gas/testsuite/gas/v850/v850e1.s	4 Sep 2003 11:04:37 -0000	1.1
+++ gas/testsuite/gas/v850/v850e1.s	13 Apr 2011 13:11:59 -0000
@@ -36,3 +36,4 @@
 	tst1	r0, [r31]
 	zxb	r3
 	zxh	r4
+	st.w    lp, 156[sp]


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