[PATCH] [ARC] Force the disassam to use the hexadecimal number for printing

Claudiu Zissulescu Claudiu.Zissulescu@synopsys.com
Fri Nov 3 11:48:00 GMT 2017


Force printing of the short/signed values using hexadecimal representation via disassembler option.

OK to apply?
Claudiu

opcode/
2017-03-30  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-03-30  Claudiu Zissulescu  <claziss@synopsys.com>

	* doc/binutils.texi (ARC): Update disassembler options.
---
 binutils/doc/binutils.texi |  7 +++++--
 opcodes/arc-dis.c          | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 98a4592..0cf3a10 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -2313,8 +2313,11 @@ special QuarkSE-EM instructions, @option{quarkse2_em} selects the
 printing of special QuarkSE2-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.
+@option{fpud} selects the printing of FPU double 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/opcodes/arc-dis.c b/opcodes/arc-dis.c
index 9473f94..a01e72e 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -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
@@ -780,6 +783,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);
 }
@@ -1265,7 +1270,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)
 	{
@@ -1378,6 +1388,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,
-- 
1.9.1



More information about the Binutils mailing list