[binutils-gdb] [ARC] Fix decoding of w6 signed short immediate.

Claudiu Zissulescu claziss@sourceware.org
Mon Jul 23 09:31:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04e65276fa99a0de996142b054bb76f8491ae103

commit 04e65276fa99a0de996142b054bb76f8491ae103
Author: Claudiu Zissulescu <claziss@gmail.com>
Date:   Mon Jul 23 11:09:43 2018 +0200

    [ARC] Fix decoding of w6 signed short immediate.
    
    gas/
      Claudiu Zissulescu  <claziss@synopsys.com>
    
            * testsuite/gas/arc/st.d: Fix test.
    
    opcodes/
      Claudiu Zissulescu  <claziss@synopsys.com>
    
            * arc-opc.c (extract_w6): Fix extending the sign.

Diff:
---
 gas/ChangeLog              | 4 ++++
 gas/testsuite/gas/arc/st.d | 2 +-
 opcodes/ChangeLog          | 4 ++++
 opcodes/arc-opc.c          | 6 +++++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index dbaa02d..8b36246 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,9 @@
 2018-07-23  Claudiu Zissulescu <claziss@synopsys.com>
 
+	* testsuite/gas/arc/st.d: Fix test.
+
+2018-07-23  Claudiu Zissulescu <claziss@synopsys.com>
+
 	* config/tc-arc.c (tokenize_extinsn): Convert to lower case the
 	name of extension instructions.
 	* testsuite/gas/arc/textinsn_case.d: New file.
diff --git a/gas/testsuite/gas/arc/st.d b/gas/testsuite/gas/arc/st.d
index 6fe5b88..269b2cf 100644
--- a/gas/testsuite/gas/arc/st.d
+++ b/gas/testsuite/gas/arc/st.d
@@ -13,7 +13,7 @@ Disassembly of section .text:
   10:	1a02 004c           	st[hw]+.aw	r1,\[r2,2\]
   14:	1e00 7040 0000 0384 	st	r1,\[0x384\]
   1c:	1a00 0003           	stb	0,\[r2\]
-  20:	1af8 8e01           	st	56,\[r2,-8\]
+  20:	1af8 8e01           	st	-8,\[r2,-8\]
   24:	1e00 7080 0000 0000 	st	r2,\[0\]
 			28: R_ARC_32_ME	foo
   2c:	1a02 0060           	st.di	r1,\[r2,2\]
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 9d0de43..d99b85c 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,9 @@
 2018-07-23  Claudiu Zissulescu <claziss@synopsys.com>
 
+	* arc-opc.c (extract_w6): Fix extending the sign.
+
+2018-07-23  Claudiu Zissulescu <claziss@synopsys.com>
+
 	* arc-tbl.h (vewt): Allow it for ARC EM family.
 
 2018-07-23  Alan Modra  <amodra@gmail.com>
diff --git a/opcodes/arc-opc.c b/opcodes/arc-opc.c
index 5349e13..b87a231 100644
--- a/opcodes/arc-opc.c
+++ b/opcodes/arc-opc.c
@@ -651,10 +651,14 @@ static long long
 extract_w6 (unsigned long long  insn,
 	    bfd_boolean *       invalid ATTRIBUTE_UNUSED)
 {
-  unsigned value = 0;
+  int value = 0;
 
   value |= ((insn >> 6) & 0x003f) << 0;
 
+  /* Extend the sign.  */
+  int signbit = 1 << 5;
+  value = (value ^ signbit) - signbit;
+
   return value;
 }



More information about the Binutils-cvs mailing list