home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / opcodes / alpha-di.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  3.6 KB  |  145 lines

  1. /* Instruction printing code for the Alpha
  2.    Copyright (C) 1993 Free Software
  3.  
  4. Foundation, Inc. Contributed by Cygnus Support. 
  5.  
  6. Written by Steve Chamberlain (sac@cygnus.com) 
  7.  
  8. This file is part of libopcodes. 
  9.  
  10. This program is free software; you can redistribute it and/or modify it under
  11. the terms of the GNU General Public License as published by the Free
  12. Software Foundation; either version 2 of the License, or (at your option)
  13. any later version. 
  14.  
  15. This program is distributed in the hope that it will be useful, but WITHOUT
  16. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  18. more details. 
  19.  
  20. You should have received a copy of the GNU General Public License along with
  21. This program; if not, write to the Free Software Foundation, Inc., 675
  22.  Mass Ave, Cambridge, MA 02139, USA.  
  23. */
  24.  
  25. #include "dis-asm.h"
  26. #define DEFINE_TABLE
  27. #include "alpha-opc.h"
  28.  
  29.  
  30. /*
  31.  * Print one instruction from MEMADDR on STREAM. Return the size of the
  32.  * instruction (always 4 on a29k).  
  33.  */
  34. int
  35. print_insn_alpha(pc, info)
  36.     bfd_vma         pc;
  37.     struct disassemble_info *info;
  38. {
  39.   alpha_insn     *insn;
  40.   unsigned  char            b[4];
  41.   void           *stream = info->stream;
  42.   fprintf_ftype   func = info->fprintf_func;
  43.   int             given;
  44.   int             status ;
  45.   int found = 0;
  46.   
  47.   status = (*info->read_memory_func) (pc, (bfd_byte *) &b[0], 4, info);
  48.   if (status != 0) {
  49.     (*info->memory_error_func) (status, pc, info);
  50.     return -1;
  51.   }
  52.   given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
  53.  
  54.   fprintf(stream, "%08x %2x ", given, (given>>26) & 0x3f);
  55.   
  56.   for (insn = alpha_insn_set;
  57.        insn->name && !found;
  58.        insn++)
  59.     {
  60.       switch (insn->type)
  61.     {
  62.     case MEMORY_FORMAT_CODE:
  63.       if ((insn->i & MEMORY_FORMAT_MASK) 
  64.           ==(given & MEMORY_FORMAT_MASK))
  65.         {
  66.           fprintf(stream, "%s\t%s, %d(%s)",
  67.               insn->name,
  68.               alpha_regs[RA(given)],
  69.               DISP(given),
  70.               alpha_regs[RB(given)]);
  71.           found = 1;
  72.         }
  73.       break;
  74.     case MEMORY_BRANCH_FORMAT_CODE:
  75.       if ((insn->i & MEMORY_BRANCH_FORMAT_MASK) 
  76.           == (given & MEMORY_BRANCH_FORMAT_MASK) )
  77.         {
  78.           fprintf(stream, "%s\t%s, 0x%lx\n",
  79.               insn->name,
  80.               alpha_regs[RA(given)],
  81.               (BDISP(given)*4) + pc);
  82.           found = 1;
  83.         }
  84.       break;
  85.  
  86.     case BRANCH_FORMAT_CODE:
  87.       if ((insn->i & BRANCH_FORMAT_MASK)
  88.           == (given & BRANCH_FORMAT_MASK))
  89.         {
  90.           if (given & (1<<15)) 
  91.         {
  92.           fprintf(stream, "%s\t%s, (%s), 1", insn->name,
  93.               alpha_regs[RA(given)],
  94.               alpha_regs[RB(given)],
  95.               alpha_regs[RC(given)]);
  96.         } 
  97.           else 
  98.         {
  99.           fprintf(stream, "%s\t%s, (%s), 0x%lx(zero)",
  100.               alpha_regs[RA(given)],
  101.               alpha_regs[RB(given)],
  102.               JUMP_HINT(given) << 2 + pc);
  103.         }
  104.           found =1 ;
  105.         }
  106.  
  107.       break;
  108.     case OPERATE_FORMAT_CODE:
  109.       if ((insn->i & OPERATE_FORMAT_MASK)
  110.           == (given & OPERATE_FORMAT_MASK)) 
  111.         {
  112.           if (OP_OPTYPE(insn->i) == OP_OPTYPE(given)) 
  113.         {
  114.           if (OP_IS_CONSTANT(given)) {
  115.             fprintf(stream, "%s\t%s, 0x%x, %s", insn->name,
  116.                 alpha_regs[RA(given)],
  117.                 LITERAL(given),
  118.                 alpha_regs[RC(given)]);
  119.           } else {
  120.             fprintf(stream, "%s\t%s, %s, %s", insn->name,
  121.                 alpha_regs[RA(given)],
  122.                 alpha_regs[RB(given)],
  123.                 alpha_regs[RC(given)]);
  124.           }
  125.           found = 1;
  126.         }
  127.         }
  128.           
  129.       break;
  130.     case FLOAT_FORMAT_CODE:
  131.       if ((insn->i & OPERATE_FORMAT_MASK)
  132.           == (given & OPERATE_FORMAT_MASK)) 
  133.         {
  134.           fprintf(stream, "%s\t%s, %s, %s", insn->name,
  135.               alpha_regs[RA(given)],
  136.               alpha_regs[RB(given)],
  137.               alpha_regs[RC(given)]);
  138.         }
  139.       found = 1;
  140.     }
  141.     }
  142.     
  143.   return 4;
  144. }
  145.