[binutils-gdb] [NIOS2] Fix disassembly of br.n instruction.
Hafiz Abid Qadeer
abidh@sourceware.org
Thu Mar 25 10:55:44 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=efa30ac3c504d24c55733a627abe49bd0368cf67
commit efa30ac3c504d24c55733a627abe49bd0368cf67
Author: Hafiz Abid Qadeer <abidh@codesourcery.com>
Date: Wed Mar 24 21:24:35 2021 +0000
[NIOS2] Fix disassembly of br.n instruction.
The code was checking wrong bit for sign extension. It caused it
to zero-extend instead of sign-extend the immediate value.
2021-03-25 Abid Qadeer <abidh@codesourcery.com>
opcodes/
* nios2-dis.c (nios2_print_insn_arg): Fix sign extension of
immediate in br.n instruction.
gas/
* testsuite/gas/nios2/brn.s: New.
* testsuite/gas/nios2/brn.d: New.
Diff:
---
gas/ChangeLog | 5 +++++
gas/testsuite/gas/nios2/brn.d | 10 ++++++++++
gas/testsuite/gas/nios2/brn.s | 4 ++++
opcodes/ChangeLog | 5 +++++
opcodes/nios2-dis.c | 2 +-
5 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index a54056667f1..f6c350dbbc1 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-25 Abid Qadeer <abidh@codesourcery.com>
+
+ * testsuite/gas/nios2/brn.d: New.
+ * testsuite/gas/nios2/brn.d: New.
+
2021-03-25 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (match_template): Use t instead of i.tm.
diff --git a/gas/testsuite/gas/nios2/brn.d b/gas/testsuite/gas/nios2/brn.d
new file mode 100644
index 00000000000..a9ed472229a
--- /dev/null
+++ b/gas/testsuite/gas/nios2/brn.d
@@ -0,0 +1,10 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: NIOS2 br.n
+#as: -march=r2
+
+.*: +file format elf32-littlenios2
+
+Disassembly of section .text:
+0+0000 <[^>]*> c4000020 nop
+0+0004 <[^>]*> ff43 br.n 00000000 <foo>
+ ...
diff --git a/gas/testsuite/gas/nios2/brn.s b/gas/testsuite/gas/nios2/brn.s
new file mode 100644
index 00000000000..84d9cf1c8f1
--- /dev/null
+++ b/gas/testsuite/gas/nios2/brn.s
@@ -0,0 +1,4 @@
+# Source file used to test the br.n instructions
+foo:
+ nop
+ br.n foo
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index a471302c3a8..53d7340f8d3 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-25 Abid Qadeer <abidh@codesourcery.com>
+
+ * nios2-dis.c (nios2_print_insn_arg): Fix sign extension of
+ immediate in br.n instruction.
+
2021-03-25 Jan Beulich <jbeulich@suse.com>
* i386-dis.c (XMGatherD, VexGatherD): New.
diff --git a/opcodes/nios2-dis.c b/opcodes/nios2-dis.c
index e1cc7169654..794d700c3e5 100644
--- a/opcodes/nios2-dis.c
+++ b/opcodes/nios2-dis.c
@@ -694,7 +694,7 @@ nios2_print_insn_arg (const char *argptr,
switch (op->format)
{
case iw_I10_type:
- o = (((GET_IW_I10_IMM10 (opcode) & 0x3ff) ^ 0x400) - 0x400) * 2;
+ o = (((GET_IW_I10_IMM10 (opcode) & 0x3ff) ^ 0x200) - 0x200) * 2;
break;
default:
bad_opcode (op);
More information about the Binutils-cvs
mailing list