[ARC] Force the disassam to use the hexadecimal number for printing
authorclaziss <claziss@synopsys.com>
Fri, 3 Nov 2017 14:36:42 +0000 (15:36 +0100)
committerclaziss <claziss@synopsys.com>
Fri, 3 Nov 2017 14:36:54 +0000 (15:36 +0100)
Force printing of the short/signed values using hexadecimal
representation via disassembler option.

opcode/
2017-11-03  Claudiu Zissulescu  <claziss@synopsys.com>

        * arc-dis.c (print_hex): New variable.
        (parse_option): Check for hex option.
        (print_insn_arc): Use hexadecimal representation for short
        immediate values when requested.
        (print_arc_disassembler_options): Add hex option to the list.

binutils/
2017-11-03  Claudiu Zissulescu  <claziss@synopsys.com>

        * doc/binutils.texi (ARC): Update disassembler options.
        * testsuite/binutils-all/arc/hexprint.s: New file.
        * testsuite/binutils-all/arc/objdump.exp: Test hex printing feature.

binutils/ChangeLog
binutils/doc/binutils.texi
binutils/testsuite/binutils-all/arc/hexprint.s [new file with mode: 0644]
binutils/testsuite/binutils-all/arc/objdump.exp
opcodes/ChangeLog
opcodes/arc-dis.c

index aa76e27cf66b657618304bf0e670b9d7a22a18c6..ede61022f615313cf275afe8f5c6dc3b9a49fc71 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-03  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * doc/binutils.texi (ARC): Update disassembler options.
+       * testsuite/binutils-all/arc/hexprint.s: New file.
+       * testsuite/binutils-all/arc/objdump.exp: Test hex printing
+       feature.
+
 2017-11-03  Mingi Cho  <mgcho.minic@gmail.com>
            Nick Clifton  <nickc@redhat.com>
 
index ad924d81629ebd9265c805c9a59767090a33f1c8..03706dbd64f1febcd61571db899be71165261daa 100644 (file)
@@ -2313,6 +2313,10 @@ special QuarkSE-EM instructions, @option{fpuda} selects the printing
 of double precision assist instructions, @option{fpus} selects the
 printing of FPU single precision FP instructions, while @option{fpud}
 selects the printing of FPU souble precision FP instructions.
+Additionally, one can choose to have all the immediates printed in
+hexadecimal using @option{hex}.  By default, the short immediates are
+printed using the decimal representation, while the long immediate
+values are printed as hexadecimal.
 
 @option{cpu=...} allows to enforce a particular ISA when disassembling
 instructions, overriding the @option{-m} value or whatever is in the ELF file.
diff --git a/binutils/testsuite/binutils-all/arc/hexprint.s b/binutils/testsuite/binutils-all/arc/hexprint.s
new file mode 100644 (file)
index 0000000..bdc61b0
--- /dev/null
@@ -0,0 +1,2 @@
+       .cpu EM
+       st r0,[r1,-9]
index 2037b2b4833efcac74984dd4b2435c5ca3f2a7b3..669d57ace75680c3bcfa90feff00daced7980b6c 100644 (file)
@@ -91,4 +91,9 @@ check_assembly "arc double_store -Mcpu=em,fpus" $objfile \
 # Make sure that the last cpu= value is used.
 check_assembly "arc double_store -Mcpu=hs,cpu=em" $objfile \
     $double_store_em_expected "-Mcpu=hs,cpu=em"
-
+# Check the hex printing for short immediates.
+set thexobj [do_objfile hexprint.s]
+check_assembly "arc hex printing" $thexobj \
+    {st\s*r0,\[r1,0xfffffff7\]} "-Mhex"
+check_assembly "arc normal printing" $thexobj \
+    {st\s*r0,\[r1,-9\]}
index b5366b5cc75c6b4c40c097b62925233f1adbafa4..ecf548d0baf5c62e43b0008e74d9d5bc46785257 100644 (file)
@@ -1,3 +1,11 @@
+2017-11-03  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * arc-dis.c (print_hex): New variable.
+       (parse_option): Check for hex option.
+       (print_insn_arc): Use hexadecimal representation for short
+       immediate values when requested.
+       (print_arc_disassembler_options): Add hex option to the list.
+
 2017-11-03  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * arc-tbl.h (abss, abssh, adc, adcs, adds, aslacc, asls, aslsacc)
index 9bfcaee1645d8288234035e6423ba12d62628a22..7541b74d23034a10fa79bc00925a0d022d805323 100644 (file)
@@ -122,6 +122,9 @@ static linkclass decodelist = NULL;
 
 static unsigned enforced_isa_mask = ARC_OPCODE_NONE;
 
+/* True if we want to print using only hex numbers.  */
+static bfd_boolean print_hex = FALSE;
+
 /* Macros section.  */
 
 #ifdef DEBUG
@@ -772,6 +775,8 @@ parse_option (const char *option)
       add_to_decodelist (FLOAT, DP);
       add_to_decodelist (FLOAT, CVT);
     }
+  else if (CONST_STRNEQ (option, "hex"))
+    print_hex = TRUE;
   else
     fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
 }
@@ -1257,7 +1262,12 @@ print_insn_arc (bfd_vma memaddr,
          if (rname && open_braket)
            (*info->fprintf_func) (info->stream, "%s", rname);
          else
-           (*info->fprintf_func) (info->stream, "%d", value);
+           {
+             if (print_hex)
+               (*info->fprintf_func) (info->stream, "%#x", value);
+             else
+               (*info->fprintf_func) (info->stream, "%d", value);
+           }
        }
       else if (operand->flags & ARC_OPERAND_ADDRTYPE)
        {
@@ -1368,6 +1378,8 @@ with -M switch (multiple options should be separated by commas):\n"));
   fpus            Recognize single precision FPU instructions.\n"));
   fprintf (stream, _("\
   fpud            Recognize double precision FPU instructions.\n"));
+  fprintf (stream, _("\
+  hex             Use only hexadecimal number to print immediates.\n"));
 }
 
 void arc_insn_decode (bfd_vma addr,
This page took 0.067684 seconds and 4 git commands to generate.