⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m68k-dis.c

📁 qemu虚拟机代码
💻 C
📖 第 1 页 / 共 5 页
字号:
   t  address test level (68030 only)      Stored as 3 bits, range 0-7.      Also used for breakpoint instruction now.*//* Places to put an operand, for non-general operands:   Characters used: BbCcDdFfGgHhIijkLlMmNnostWw123456789/   s  source, low bits of first word.   d  dest, shifted 9 in first word   1  second word, shifted 12   2  second word, shifted 6   3  second word, shifted 0   4  third word, shifted 12   5  third word, shifted 6   6  third word, shifted 0   7  second word, shifted 7   8  second word, shifted 10   9  second word, shifted 5   D  store in both place 1 and place 3; for divul and divsl.   B  first word, low byte, for branch displacements   W  second word (entire), for branch displacements   L  second and third words (entire), for branch displacements      (also overloaded for move16)   b  second word, low byte   w  second word (entire) [variable word/long branch offset for dbra]   W  second word (entire) (must be signed 16 bit value)   l  second and third word (entire)   g  variable branch offset for bra and similar instructions.      The place to store depends on the magnitude of offset.   t  store in both place 7 and place 8; for floating point operations   c  branch offset for cpBcc operations.      The place to store is word two if bit six of word one is zero,      and words two and three if bit six of word one is one.   i  Increment by two, to skip over coprocessor extended operands.   Only      works with the 'I' format.   k  Dynamic K-factor field.   Bits 6-4 of word 2, used as a register number.      Also used for dynamic fmovem instruction.   C  floating point coprocessor constant - 7 bits.  Also used for static      K-factors...   j  Movec register #, stored in 12 low bits of second word.   m  For M[S]ACx; 4 bits split with MSB shifted 6 bits in first word      and remaining 3 bits of register shifted 9 bits in first word.      Indicate upper/lower in 1 bit shifted 7 bits in second word.      Use with `R' or `u' format.   n  `m' withouth upper/lower indication. (For M[S]ACx; 4 bits split      with MSB shifted 6 bits in first word and remaining 3 bits of      register shifted 9 bits in first word.  No upper/lower      indication is done.)  Use with `R' or `u' format.   o  For M[S]ACw; 4 bits shifted 12 in second word (like `1').      Indicate upper/lower in 1 bit shifted 7 bits in second word.      Use with `R' or `u' format.   M  For M[S]ACw; 4 bits in low bits of first word.  Indicate      upper/lower in 1 bit shifted 6 bits in second word.  Use with      `R' or `u' format.   N  For M[S]ACw; 4 bits in low bits of second word.  Indicate      upper/lower in 1 bit shifted 6 bits in second word.  Use with      `R' or `u' format.   h  shift indicator (scale factor), 1 bit shifted 10 in second word Places to put operand, for general operands:   d  destination, shifted 6 bits in first word   b  source, at low bit of first word, and immediate uses one byte   w  source, at low bit of first word, and immediate uses two bytes   l  source, at low bit of first word, and immediate uses four bytes   s  source, at low bit of first word.      Used sometimes in contexts where immediate is not allowed anyway.   f  single precision float, low bit of 1st word, immediate uses 4 bytes   F  double precision float, low bit of 1st word, immediate uses 8 bytes   x  extended precision float, low bit of 1st word, immediate uses 12 bytes   p  packed float, low bit of 1st word, immediate uses 12 bytes   G  EMAC accumulator, load  (bit 4 2nd word, !bit8 first word)   H  EMAC accumulator, non load  (bit 4 2nd word, bit 8 first word)   F  EMAC ACCx   f  EMAC ACCy   I  MAC/EMAC scale factor   /  Like 's', but set 2nd word, bit 5 if trailing_ampersand set   ]  first word, bit 10*/extern const struct m68k_opcode m68k_opcodes[];extern const struct m68k_opcode_alias m68k_opcode_aliases[];extern const int m68k_numopcodes, m68k_numaliases;/* **** End of m68k-opcode.h *//* **** m68k-dis.c from sourceware.org CVS 2005-08-14.  *//* Print Motorola 68k instructions.   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005   Free Software Foundation, Inc.   This file is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,   MA 02110-1301, USA.  *//* Local function prototypes.  */const char * const fpcr_names[] ={  "", "%fpiar", "%fpsr", "%fpiar/%fpsr", "%fpcr",  "%fpiar/%fpcr", "%fpsr/%fpcr", "%fpiar/%fpsr/%fpcr"};static char *const reg_names[] ={  "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp",  "%ps", "%pc"};/* Name of register halves for MAC/EMAC.   Seperate from reg_names since 'spu', 'fpl' look weird.  */static char *const reg_half_names[] ={  "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",  "%ps", "%pc"};/* Sign-extend an (unsigned char).  */#if __STDC__ == 1#define COERCE_SIGNED_CHAR(ch) ((signed char) (ch))#else#define COERCE_SIGNED_CHAR(ch) ((int) (((ch) ^ 0x80) & 0xFF) - 128)#endif/* Get a 1 byte signed integer.  */#define NEXTBYTE(p)  (p += 2, FETCH_DATA (info, p), COERCE_SIGNED_CHAR(p[-1]))/* Get a 2 byte signed integer.  */#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))#define NEXTWORD(p)  \  (p += 2, FETCH_DATA (info, p), \   COERCE16 ((p[-2] << 8) + p[-1]))/* Get a 4 byte signed integer.  */#define COERCE32(x) ((bfd_signed_vma) ((x) ^ 0x80000000) - 0x80000000)#define NEXTLONG(p)  \  (p += 4, FETCH_DATA (info, p), \   (COERCE32 ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1])))/* Get a 4 byte unsigned integer.  */#define NEXTULONG(p)  \  (p += 4, FETCH_DATA (info, p), \   (unsigned int) ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]))/* Get a single precision float.  */#define NEXTSINGLE(val, p) \  (p += 4, FETCH_DATA (info, p), \   floatformat_to_double (&floatformat_ieee_single_big, (char *) p - 4, &val))/* Get a double precision float.  */#define NEXTDOUBLE(val, p) \  (p += 8, FETCH_DATA (info, p), \   floatformat_to_double (&floatformat_ieee_double_big, (char *) p - 8, &val))/* Get an extended precision float.  */#define NEXTEXTEND(val, p) \  (p += 12, FETCH_DATA (info, p), \   floatformat_to_double (&floatformat_m68881_ext, (char *) p - 12, &val))/* Need a function to convert from packed to double   precision.   Actually, it's easier to print a   packed number than a double anyway, so maybe   there should be a special case to handle this... */#define NEXTPACKED(p) \  (p += 12, FETCH_DATA (info, p), 0.0)/* Maximum length of an instruction.  */#define MAXLEN 22#include <setjmp.h>struct private{  /* Points to first byte not fetched.  */  bfd_byte *max_fetched;  bfd_byte the_buffer[MAXLEN];  bfd_vma insn_start;  jmp_buf bailout;};/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)   to ADDR (exclusive) are valid.  Returns 1 for success, longjmps   on error.  */#define FETCH_DATA(info, addr) \  ((addr) <= ((struct private *) (info->private_data))->max_fetched \   ? 1 : fetch_data ((info), (addr)))static intfetch_data (struct disassemble_info *info, bfd_byte *addr){  int status;  struct private *priv = (struct private *)info->private_data;  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);  status = (*info->read_memory_func) (start,				      priv->max_fetched,				      addr - priv->max_fetched,				      info);  if (status != 0)    {      (*info->memory_error_func) (status, start, info);      longjmp (priv->bailout, 1);    }  else    priv->max_fetched = addr;  return 1;}/* This function is used to print to the bit-bucket.  */static intdummy_printer (FILE *file ATTRIBUTE_UNUSED,	       const char *format ATTRIBUTE_UNUSED,	       ...){  return 0;}static voiddummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,		     struct disassemble_info *info ATTRIBUTE_UNUSED){}/* Fetch BITS bits from a position in the instruction specified by CODE.   CODE is a "place to put an argument", or 'x' for a destination   that is a general address (mode and register).   BUFFER contains the instruction.  */static intfetch_arg (unsigned char *buffer,	   int code,	   int bits,	   disassemble_info *info){  int val = 0;  switch (code)    {    case '/': /* MAC/EMAC mask bit.  */      val = buffer[3] >> 5;      break;    case 'G': /* EMAC ACC load.  */      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);      break;    case 'H': /* EMAC ACC !load.  */      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);      break;    case ']': /* EMAC ACCEXT bit.  */      val = buffer[0] >> 2;      break;    case 'I': /* MAC/EMAC scale factor.  */      val = buffer[2] >> 1;      break;    case 'F': /* EMAC ACCx.  */      val = buffer[0] >> 1;      break;    case 'f':      val = buffer[1];      break;    case 's':      val = buffer[1];      break;    case 'd':			/* Destination, for register or quick.  */      val = (buffer[0] << 8) + buffer[1];      val >>= 9;      break;    case 'x':			/* Destination, for general arg.  */      val = (buffer[0] << 8) + buffer[1];      val >>= 6;      break;    case 'k':      FETCH_DATA (info, buffer + 3);      val = (buffer[3] >> 4);      break;    case 'C':      FETCH_DATA (info, buffer + 3);      val = buffer[3];      break;    case '1':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      val >>= 12;      break;    case '2':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      val >>= 6;      break;    case '3':    case 'j':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      break;    case '4':      FETCH_DATA (info, buffer + 5);      val = (buffer[4] << 8) + buffer[5];      val >>= 12;      break;    case '5':      FETCH_DATA (info, buffer + 5);      val = (buffer[4] << 8) + buffer[5];      val >>= 6;      break;    case '6':      FETCH_DATA (info, buffer + 5);      val = (buffer[4] << 8) + buffer[5];      break;    case '7':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      val >>= 7;      break;    case '8':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      val >>= 10;      break;    case '9':      FETCH_DATA (info, buffer + 3);      val = (buffer[2] << 8) + buffer[3];      val >>= 5;      break;    case 'e':      val = (buffer[1] >> 6);      break;    case 'm':      val = (buffer[1] & 0x40 ? 0x8 : 0)	| ((buffer[0] >> 1) & 0x7)	| (buffer[3] & 0x80 ? 0x10 : 0);      break;    case 'n':      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);      break;    case 'o':      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);      break;    case 'M':      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);      break;    case 'N':      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);      break;    case 'h':      val = buffer[2] >> 2;      break;    default:      abort ();    }  switch (bits)    {    case 1:      return val & 1;    case 2:      return val & 3;    case 3:      return val & 7;    case 4:      return val & 017;    case 5:      return val & 037;    case 6:      return val & 077;    case 7:      return val & 0177;    case 8:      return val & 0377;    case 12:      return val & 07777;    default:      abort ();    }}/* Check if an EA is valid for a particular code.  This is required   for the EMAC instructions since the type of source address determines   if it is a EMAC-load instruciton if the EA is mode 2-5, otherwise it   is a non-load EMAC instruction and the bits mean register Ry.   A similar case exists for the movem instructions where the register   mask is interpreted differently for different EAs.  */static bfd_booleanm68k_valid_ea (char code, int val){  int mode, mask;#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)  switch (code)    {    case '*':      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -