[NIOS2] Fix disassembly of br.n instruction.
authorHafiz Abid Qadeer <abidh@codesourcery.com>
Wed, 24 Mar 2021 21:24:35 +0000 (21:24 +0000)
committerHafiz Abid Qadeer <abidh@codesourcery.com>
Thu, 25 Mar 2021 10:52:14 +0000 (10:52 +0000)
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.

gas/ChangeLog
gas/testsuite/gas/nios2/brn.d [new file with mode: 0644]
gas/testsuite/gas/nios2/brn.s [new file with mode: 0644]
opcodes/ChangeLog
opcodes/nios2-dis.c

index a54056667f1e405154c6891449898738d036dbaf..f6c350dbbc1ccf103d2f8ef6aa09b140d40d1944 100644 (file)
@@ -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 (file)
index 0000000..a9ed472
--- /dev/null
@@ -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 (file)
index 0000000..84d9cf1
--- /dev/null
@@ -0,0 +1,4 @@
+# Source file used to test the br.n instructions
+foo:
+       nop
+       br.n foo
index a471302c3a84c2139899654e75c44418d603b9c7..53d7340f8d36726c76520a460d6d120f4505d6a7 100644 (file)
@@ -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.
index e1cc716965410ffc83acec1eedc2c5c19acc3fa5..794d700c3e53f98915ef1f7103929e214eb2a7c0 100644 (file)
@@ -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);