m10300-dis.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 688 行 · 第 1/2 页

C
688
字号
	    }	  else if (size == 5)	    {	      unsigned long temp = 0;	      status = (*info->read_memory_func) (memaddr + 1, buffer, 2, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      temp |= bfd_getl16 (buffer);	      insn &= 0xff0000ff;	      insn |= temp << 8;	      status = (*info->read_memory_func) (memaddr + 4, buffer, 1, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      extension = *(unsigned char *)buffer;	    }	  else if (size == 6 && op->format == FMT_D8)	    {	      insn &= 0xffffff00;	      status = (*info->read_memory_func) (memaddr + 5, buffer, 1, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      insn |= *(unsigned char *)buffer;	      status = (*info->read_memory_func) (memaddr + 3, buffer, 2, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      extension = bfd_getl16 (buffer);	    }	  else if (size == 6)	    {	      unsigned long temp = 0;	      status = (*info->read_memory_func) (memaddr + 2, buffer, 4, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      temp |= bfd_getl32 (buffer);	      insn &= 0xffff0000;	      insn |= (temp >> 16) & 0xffff;	      extension = temp & 0xffff;	    }	  else if (size == 7 && op->format == FMT_D9)	    {	      insn &= 0xffffff00;	      status = (*info->read_memory_func) (memaddr + 3, buffer, 4, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      extension = bfd_getl32 (buffer);	      insn |= (extension & 0xff000000) >> 24;	      extension &= 0xffffff;	    }	  else if (size == 7 && op->opcode == 0xdd000000)	    {	      unsigned long temp = 0;	      status = (*info->read_memory_func) (memaddr + 1, buffer, 4, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      temp |= bfd_getl32 (buffer);	      insn &= 0xff000000;	      insn |= (temp >> 8) & 0xffffff;	      extension = (temp & 0xff) << 16;	      	      status = (*info->read_memory_func) (memaddr + 5, buffer, 2, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      extension |= bfd_getb16 (buffer);	    }	  else if (size == 7)	    {	      unsigned long temp = 0;	      status = (*info->read_memory_func) (memaddr + 2, buffer, 4, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      temp |= bfd_getl32 (buffer);	      insn &= 0xffff0000;	      insn |= (temp >> 16) & 0xffff;	      extension = (temp & 0xffff) << 8;	      	      status = (*info->read_memory_func) (memaddr + 6, buffer, 1, info);	      if (status != 0)		{		  (*info->memory_error_func) (status, memaddr, info);		  return;		}	      extension |= *(unsigned char *)buffer;	    }	  match = 1;	  (*info->fprintf_func) (info->stream, "%s\t", op->name);	  /* Now print the operands.  */	  for (opindex_ptr = op->operands, nocomma = 1;	       *opindex_ptr != 0;	       opindex_ptr++)	    {	      unsigned long value;	      operand = &mn10300_operands[*opindex_ptr];	      /* If this operand is a PLUS (autoincrement), then do not emit		 a comma before emitting the plus.  */	      if ((operand->flags & MN10300_OPERAND_PLUS) != 0)		nocomma = 1;	      if ((operand->flags & MN10300_OPERAND_SPLIT) != 0)		{		  unsigned long temp;		  value = insn & ((1 << operand->bits) - 1);		  value <<= (32 - operand->bits);		  temp = extension >> operand->shift;		  temp &= ((1 << (32 - operand->bits)) - 1);		  value |= temp;		  value = ((value ^ (((unsigned long)1) << 31))			   - (((unsigned long)1) << 31));		}	      else if ((operand->flags & MN10300_OPERAND_24BIT) != 0)		{		  unsigned long temp;		  value = insn & ((1 << operand->bits) - 1);		  value <<= (24 - operand->bits);		  temp = extension >> operand->shift;		  temp &= ((1 << (24 - operand->bits)) - 1);		  value |= temp;		  if ((operand->flags & MN10300_OPERAND_SIGNED) != 0)		    value = ((value & 0xffffff) ^ 0x800000) - 0x800000;		}	      else if ((operand->flags & MN10300_OPERAND_EXTENDED) != 0)		{		  value = ((extension >> (operand->shift))			   & ((1 << operand->bits) - 1));		}	      else		{		  value = ((insn >> (operand->shift))			   & ((1 << operand->bits) - 1));		}	      if ((operand->flags & MN10300_OPERAND_SIGNED) != 0		  /* These are properly extended by the code above.  */		  && ((operand->flags & MN10300_OPERAND_24BIT) == 0))		value = ((value ^ (((unsigned long)1) << (operand->bits - 1)))			 - (((unsigned long)1) << (operand->bits - 1)));	      if (!nocomma		  && (!paren		      || ((operand->flags & MN10300_OPERAND_PAREN) == 0)))		(*info->fprintf_func) (info->stream, ",");	      nocomma = 0;			      if ((operand->flags & MN10300_OPERAND_DREG) != 0)		{		  value = ((insn >> (operand->shift + extra_shift))			   & ((1 << operand->bits) - 1));		  (*info->fprintf_func) (info->stream, "d%d", (int)value);		}	      else if ((operand->flags & MN10300_OPERAND_AREG) != 0)		{		  value = ((insn >> (operand->shift + extra_shift))			   & ((1 << operand->bits) - 1));		  (*info->fprintf_func) (info->stream, "a%d", (int)value);		}	      else if ((operand->flags & MN10300_OPERAND_SP) != 0)		(*info->fprintf_func) (info->stream, "sp");	      else if ((operand->flags & MN10300_OPERAND_PSW) != 0)		(*info->fprintf_func) (info->stream, "psw");	      else if ((operand->flags & MN10300_OPERAND_MDR) != 0)		(*info->fprintf_func) (info->stream, "mdr");	      else if ((operand->flags & MN10300_OPERAND_RREG) != 0)		{		  value = ((insn >> (operand->shift + extra_shift))			   & ((1 << operand->bits) - 1));		  if (value < 8)		    (*info->fprintf_func) (info->stream, "r%d", (int)value);		  else if (value < 12)		    (*info->fprintf_func) (info->stream, "a%d", (int)value - 8);		  else		    (*info->fprintf_func) (info->stream, "d%d", (int)value - 12);		}	      else if ((operand->flags & MN10300_OPERAND_XRREG) != 0)		{		  value = ((insn >> (operand->shift + extra_shift))			   & ((1 << operand->bits) - 1));		  if (value == 0)		    (*info->fprintf_func) (info->stream, "sp", value);		  else		  (*info->fprintf_func) (info->stream, "xr%d", (int)value);		}	      else if ((operand->flags & MN10300_OPERAND_USP) != 0)		(*info->fprintf_func) (info->stream, "usp");	      else if ((operand->flags & MN10300_OPERAND_SSP) != 0)		(*info->fprintf_func) (info->stream, "ssp");	      else if ((operand->flags & MN10300_OPERAND_MSP) != 0)		(*info->fprintf_func) (info->stream, "msp");	      else if ((operand->flags & MN10300_OPERAND_PC) != 0)		(*info->fprintf_func) (info->stream, "pc");	      else if ((operand->flags & MN10300_OPERAND_EPSW) != 0)		(*info->fprintf_func) (info->stream, "epsw");	      else if ((operand->flags & MN10300_OPERAND_PLUS) != 0)		(*info->fprintf_func) (info->stream, "+");	      else if ((operand->flags & MN10300_OPERAND_PAREN) != 0)		{		  if (paren)		    (*info->fprintf_func) (info->stream, ")");		  else		    {		      (*info->fprintf_func) (info->stream, "(");		      nocomma = 1;		    }		  paren = !paren;		}	      else if ((operand->flags & MN10300_OPERAND_PCREL) != 0)		(*info->print_address_func) ((long) value + memaddr, info);	      else if ((operand->flags & MN10300_OPERAND_MEMADDR) != 0)		(*info->print_address_func) (value, info);	      else if ((operand->flags & MN10300_OPERAND_REG_LIST) != 0)		{		  int comma = 0;		  (*info->fprintf_func) (info->stream, "[");		  if (value & 0x80)		    {		      (*info->fprintf_func) (info->stream, "d2");		      comma = 1;		    }		  if (value & 0x40)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "d3");		      comma = 1;		    }		  if (value & 0x20)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "a2");		      comma = 1;		    }		  if (value & 0x10)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "a3");		      comma = 1;		    }		  if (value & 0x08)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "other");		      comma = 1;		    }		  if (value & 0x04)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "exreg0");		      comma = 1;		    }		  if (value & 0x02)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "exreg1");		      comma = 1;		    }		  if (value & 0x01)		    {		      if (comma)			(*info->fprintf_func) (info->stream, ",");		      (*info->fprintf_func) (info->stream, "exother");		      comma = 1;		    }		  (*info->fprintf_func) (info->stream, "]");		}	      else 		(*info->fprintf_func) (info->stream, "%ld", (long)value);	    }	  /* All done. */	  break;	}      op++;    }  if (!match)    {      /* xgettext:c-format */      (*info->fprintf_func) (info->stream, _("unknown\t0x%04x"), insn);    }}

⌨️ 快捷键说明

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