New dummy function for symbol_at_address_func field of disassemble_info
authorNick Clifton <nickc@redhat.com>
Tue, 14 Oct 1997 23:09:59 +0000 (23:09 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 14 Oct 1997 23:09:59 +0000 (23:09 +0000)
structure.
Add code to use this field in v850 disassembly.

opcodes/ChangeLog
opcodes/v850-dis.c

index 3fc8cde..71c3bdb 100644 (file)
@@ -1,3 +1,12 @@
+Tue Oct 14 16:10:31 1997  Nick Clifton  <nickc@cygnus.com>
+
+       * v850-dis.c (disassemble): Use new symbol_at_address_func() field
+       of disassemble_info structure to determine if an overlay address
+       has a matching symbol in low memory.
+
+       * dis-buf.c (generic_symbol_at_address): New (dummy) function for
+       new symbol_at_address_func field in disassemble_info structure.
+
 Fri Oct 10 16:44:52 1997  Nick Clifton  <nickc@cygnus.com>
 
        * v850-opc.c (extract_d22): Use signed arithmatic.
index 34e49e2..c43f6db 100644 (file)
@@ -30,7 +30,11 @@ static const char *const v850_reg_names[] =
 
 static const char *const v850_sreg_names[] =
 { "eipc", "eipsw", "fepc", "fepsw", "ecr", "psw", "sr6", "sr7", 
-  "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15", 
+  "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15",
+/* start-sanitize-v850e */
+  "ctpc", "ctpsw", "dbpc", "dbpsw", "ctbp", "sr21", "sr22", "sr23", 
+  "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
+/* end-sanitize-v850e */
   "sr16", "sr17", "sr18", "sr19", "sr20", "sr21", "sr22", "sr23", 
   "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31" };
 
@@ -175,12 +179,35 @@ disassemble (memaddr, info, insn)
                case V850_OPERAND_SRG:  info->fprintf_func (info->stream, "%s", v850_sreg_names[value]); break;
                case V850_OPERAND_CC:   info->fprintf_func (info->stream, "%s", v850_cc_names[value]); break;
                case V850_OPERAND_EP:   info->fprintf_func (info->stream, "ep"); break;
-               case V850_OPERAND_DISP: info->print_address_func (value + memaddr, info); break;
                default:                info->fprintf_func (info->stream, "%d", value); break;
+               case V850_OPERAND_DISP:
+                 {
+                   bfd_vma addr = value + memaddr;
+                   
+                   /* On the v850 the top 8 bits of an address are used by an overlay manager.
+                      Thus it may happen that when we are looking for a symbol to match
+                      against an address with some of its top bits set, the search fails to
+                      turn up an exact match.  In this case we try to find an exact match
+                      against a symbol in the lower address space, and if we find one, we
+                      use that address.   We only do this for JARL instructions however, as
+                      we do not want to misinterpret branch instructions.  */
+                   if (operand->bits == 22)
+                     {
+                       if ( ! info->symbol_at_address_func (addr, info)
+                           && ((addr & 0xFF000000) != 0)
+                           && info->symbol_at_address_func (addr & 0x00FFFFFF, info))
+                         {
+                           addr &= 0x00FFFFFF;
+                         }
+                     }
+                   info->print_address_func (addr, info);
+                   break;
+                 }
+                   
 /* start-sanitize-v850e */
                case V850E_PUSH_POP:
                  {
-                   static int list12_regs[32] = { 30,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 };
+                   static int list12_regs[32]   = { 30,  0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 };
                    static int list18_h_regs[32] = { 19, 18, 17, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 30, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 };
                    static int list18_l_regs[32] = {  3,  2,  1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 14, 15, 13, 12,  7,  6,  5,  4, 11, 10,  9,  8 };
                    int *             regs;
@@ -357,5 +384,3 @@ print_insn_v850 (memaddr, info)
   /* Make sure we tell our caller how many bytes we consumed.  */
   return disassemble (memaddr, info, insn);
 }
-
-