[1/3] Fix decoding of w6 signed short immediate.

Message ID 20180717085633.15086-1-claziss@gmail.com
State New
Headers show
Series
  • [1/3] Fix decoding of w6 signed short immediate.
Related show

Commit Message

Claudiu Zissulescu July 17, 2018, 8:56 a.m.
The decoding of w6 type immediate is wrong. Fix it and update the test.

Ok to apply?
Claudiu

gas/
2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

        * testsuite/gas/arc/st.d: Fix test.

opcodes/
2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

        * arc-opc.c (extract_w6): Fix extending the sign.
---
 gas/testsuite/gas/arc/st.d | 2 +-
 opcodes/arc-opc.c          | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Nick Clifton July 18, 2018, 9:06 a.m. | #1
Hi Claudiu,

> gas/

> 2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

> 

>         * testsuite/gas/arc/st.d: Fix test.

> 

> opcodes/

> 2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

> 

>         * arc-opc.c (extract_w6): Fix extending the sign.


Approved - please apply.

Cheers
  Nick
Claudiu Zissulescu July 24, 2018, 2:29 p.m. | #2
Done for all three patches.

Thank you for your review,
Claudiu
________________________________________
From: Nick Clifton [nickc@redhat.com]

Sent: Wednesday, July 18, 2018 11:06 AM
To: Claudiu Zissulescu; binutils@sourceware.org
Cc: Francois.Bedard@synopsys.com; Claudiu.Zissulescu@synopsys.com
Subject: Re: [PATCH 1/3] Fix decoding of w6 signed short immediate.

Hi Claudiu,

> gas/

> 2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

>

>         * testsuite/gas/arc/st.d: Fix test.

>

> opcodes/

> 2018-05-03  Claudiu Zissulescu  <claziss@synopsys.com>

>

>         * arc-opc.c (extract_w6): Fix extending the sign.


Approved - please apply.

Cheers
  Nick

Patch

diff --git a/gas/testsuite/gas/arc/st.d b/gas/testsuite/gas/arc/st.d
index 6fe5b88aef..269b2cf46d 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/arc-opc.c b/opcodes/arc-opc.c
index 5349e13031..b87a231485 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;
 }