Allow symbol and label names to be enclosed in double quotes.
[binutils-gdb.git] / opcodes / rl78-dis.c
index 68904a02b4f1607f296445d00991c8af86cad05a..0d98d00e5e39edb3c190ab50f703628cdc879385 100644 (file)
@@ -1,5 +1,5 @@
 /* Disassembler code for Renesas RL78.
-   Copyright (C) 2011-2014 Free Software Foundation, Inc.
+   Copyright (C) 2011-2015 Free Software Foundation, Inc.
    Contributed by Red Hat.
    Written by DJ Delorie.
 
 #include <stdio.h>
 
 #include "bfd.h"
+#include "elf-bfd.h"
 #include "dis-asm.h"
 #include "opcode/rl78.h"
+#include "elf/rl78.h"
 
 #define DEBUG_SEMANTICS 0
 
@@ -80,8 +82,8 @@ indirect_type (int t)
     }
 }
 
-int
-print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
+static int
+print_insn_rl78_common (bfd_vma addr, disassemble_info * dis, RL78_Dis_Isa isa)
 {
   int rv;
   RL78_Data rl78_data;
@@ -94,7 +96,7 @@ print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
   rl78_data.pc = addr;
   rl78_data.dis = dis;
 
-  rv = rl78_decode_opcode (addr, &opcode, rl78_get_byte, &rl78_data);
+  rv = rl78_decode_opcode (addr, &opcode, rl78_get_byte, &rl78_data, isa);
 
   dis->bytes_per_line = 10;
 
@@ -202,7 +204,7 @@ print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
                {
                  char *comma = "";
                  PR (PS, "  \033[35m");
-             
+
                  if (opcode.flags & RL78_PSW_Z)
                    { PR (PS, "Z"); comma = ","; }
                  if (opcode.flags & RL78_PSW_AC)
@@ -284,11 +286,11 @@ print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
                    PR (PS, "[%s", register_names[oper->reg]);
                    if (oper->reg2 != RL78_Reg_None)
                      PR (PS, "+%s", register_names[oper->reg2]);
-                   if (oper->addend)
+                   if (oper->addend || do_addr)
                      PR (PS, "+%d", oper->addend);
                    PC (']');
                    break;
-                     
+
                  }
                if (oper->type == RL78_Operand_BitIndirect)
                  PR (PS, ".%d", oper->bit_number);
@@ -327,3 +329,44 @@ print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
 
   return rv;
 }
+
+int
+print_insn_rl78 (bfd_vma addr, disassemble_info * dis)
+{
+  return print_insn_rl78_common (addr, dis, RL78_ISA_DEFAULT);
+}
+
+int
+print_insn_rl78_g10 (bfd_vma addr, disassemble_info * dis)
+{
+  return print_insn_rl78_common (addr, dis, RL78_ISA_G10);
+}
+
+int
+print_insn_rl78_g13 (bfd_vma addr, disassemble_info * dis)
+{
+  return print_insn_rl78_common (addr, dis, RL78_ISA_G13);
+}
+
+int
+print_insn_rl78_g14 (bfd_vma addr, disassemble_info * dis)
+{
+  return print_insn_rl78_common (addr, dis, RL78_ISA_G14);
+}
+
+disassembler_ftype
+rl78_get_disassembler (bfd *abfd)
+{
+  int cpu = abfd->tdata.elf_obj_data->elf_header->e_flags & E_FLAG_RL78_CPU_MASK;
+  switch (cpu)
+    {
+    case E_FLAG_RL78_G10:
+      return print_insn_rl78_g10;
+    case E_FLAG_RL78_G13:
+      return print_insn_rl78_g13;
+    case E_FLAG_RL78_G14:
+      return print_insn_rl78_g14;
+    default:
+      return print_insn_rl78;
+    }
+}