📄 disasm.c
字号:
/* MULS MULU .W */
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
append_register(dstr,opword,DATA_REGISTER,11);
}
/********************************************************************/
static void
func39 (int index, uint16 opword)
{
/* MULS MULU .L */
int opword2,size;
opword2 = (int)((uint16)cpu_read_data((ADDRESS)disasm_pc,16));
inc_disasm_pc(2);
switch (opword2 & 0x8FF8)
{
case 0x0000:
append_instruction(dstr,"MULU.L");
size=32;
break;
case 0x0400:
append_instruction(dstr,"MULU.L");
size=64;
break;
case 0x0800:
append_instruction(dstr,"MULS.L");
size=32;
break;
case 0x0C00:
append_instruction(dstr,"MULS.L");
size=64;
break;
default:
valid_instruction = FALSE;
return;
}
if (size == 32)
{
/* 32 bit */
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
append_register(dstr,opword2,DATA_REGISTER,14);
}
else
{
/* 64 bit */
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
append_register(dstr,opword2,DATA_REGISTER,2);
append_string(dstr,"-");
append_register(dstr,opword2,DATA_REGISTER,14);
}
}
/********************************************************************/
static void
func47 (int index, uint16 opword)
{
/* EOR SUB ADD OR */
append_size(dstr,opword,7,TRUE);
append_register(dstr,opword,DATA_REGISTER,11);
append_string(dstr,",");
append_ea(dstr,opword,5,isa[index].ea_mask);
}
/********************************************************************/
#ifdef CPU_MCF_DIV
static void
func54 (int index, uint16 opword)
{
/* DIVS.W DIVU.W */
if (opword & 0x0100)
append_instruction(dstr,"DIVS.W");
else
append_instruction(dstr,"DIVU.W");
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
append_register(dstr,opword,DATA_REGISTER,11);
}
/********************************************************************/
static void
func55 (int index, uint16 opword)
{
/* DIVS.L DIVU.L DIVSL.L DIVUL.L REMS.L REMU.L*/
int opword2, same_reg;
opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
inc_disasm_pc(2);
same_reg = (((opword2 & 0x7000) >> 12) ==
(opword2 & 0x0007));
if (opword2 & 0x0800) /* DIVS or DIVSL or REMS */
{
if (same_reg) /* DIVS */
append_instruction(dstr,"DIVS.L");
else if (opword2 & 0x0400) /* DIVSL */
append_instruction(dstr,"DIVSL.L");
else /* REMS */
append_instruction(dstr,"REMS.L");
}
else /* DIVU or DIVUL or REMU */
{
if (same_reg) /* DIVU */
append_instruction(dstr,"DIVU.L");
else if (opword2 & 0x0400) /* DIVUL */
append_instruction(dstr,"DIVUL.L");
else /* REMU */
append_instruction(dstr,"REMU.L");
}
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
if (same_reg)
{
append_register(dstr,opword2,DATA_REGISTER,14);
}
else
{
append_register(dstr,opword2,DATA_REGISTER,2);
append_string(dstr,":");
append_register(dstr,opword2,DATA_REGISTER,14);
}
}
#endif /* #ifdef CPU_MCF_DIV */
/********************************************************************/
#ifdef CPU_MCF_MAC
static void
mac1 (int index, uint16 opword)
{
/* MAC.W Rw,Rx */
/* MAC.L Rw,Rx */
/* MSAC.W Rw,Rx */
/* MSAC.L Rw,Rx */
int opword2;
(void)index;
opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
inc_disasm_pc(2);
if (opword2 & 0x0100) /* if MSAC */
{
if (opword2 & 0x0800)
append_instruction(dstr,"MSAC.L");
else
append_instruction(dstr,"MSAC.W");
}
else /* else MAC */
{
if (opword2 & 0x0800)
append_instruction(dstr,"MAC.L");
else
append_instruction(dstr,"MAC.W");
}
append_register(dstr,opword,6,11); /* Ry */
if (opword2 & 0x0080)
append_string(dstr,".U,");
else
append_string(dstr,".L,");
append_register(dstr,opword,3,2); /* Rx */
if (opword2 & 0x0040)
append_string(dstr,".U");
else
append_string(dstr,".L");
if ((opword2 & 0x0600) == 0x0200)
append_string(dstr,",<<1");
else if ((opword2 & 0x0600) == 0x0600)
append_string(dstr,",>>1");
}
/********************************************************************/
static void
mac2 (int index, uint16 opword)
{
/* MACL.W Rw,Rx */
/* MACL.L Rw,Rx */
/* MSACL.W Rw,Rx */
/* MSACL.L Rw,Rx */
int opword2;
(void)index;
opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
inc_disasm_pc(2);
if (opword2 & 0x0100)
{
if (opword2 & 0x0800)
append_instruction(dstr,"MSACL.L");
else
append_instruction(dstr,"MSACL.W");
}
else
{
if (opword2 & 0x0800)
append_instruction(dstr,"MACL.L");
else
append_instruction(dstr,"MACL.W");
}
append_register(dstr,opword,6,11); /* Ry */
if (opword2 & 0x0080)
append_string(dstr,".U,");
else
append_string(dstr,".L,");
append_register(dstr,opword2,3,2); /* Rx */
if (opword2 & 0x0040)
append_string(dstr,".U,");
else
append_string(dstr,".L,");
if ((opword2 & 0x0600) == 0x0200)
append_string(dstr,"<<1,");
else if ((opword2 & 0x0600) == 0x0600)
append_string(dstr,">>1,");
append_ea(dstr,opword,5,isa[index].ea_mask);
if ((opword2 & 0x0020)== 0x0020)
append_string(dstr,"&");
append_string(dstr,",");
append_register(dstr,opword2,15,14); /* Rw */
}
/********************************************************************/
static void
mac3 (int index, uint16 opword)
{
/* MOVE.L <ea>,ACC */
(void)index;
append_size(dstr,opword,13,TRUE);
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",ACC");
}
/********************************************************************/
static void
mac4 (int index, uint16 opword)
{
/* MOVE.L <ea>,MACSR */
(void)index;
append_size(dstr,opword,13,TRUE);
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",MACSR");
}
/********************************************************************/
static void
mac5 (int index, uint16 opword)
{
/* MOVE.L ACC,Rx */
(void)index;
append_size(dstr,opword,13,TRUE);
append_string(dstr,"ACC,");
append_register(dstr,opword,3,2);
}
/********************************************************************/
static void
mac6 (int index, uint16 opword)
{
/* MOVE.L MACSR,Rx */
(void)index;
append_size(dstr,opword,13,TRUE);
append_string(dstr,"MACSR,");
append_register(dstr,opword,3,2);
}
/********************************************************************/
static void
mac7 (int index, uint16 opword)
{
/* MOVE.L MACSR,CCR */
(void)index;
(void)opword;
append_size(dstr,opword,13,TRUE);
append_string(dstr,"MACSR,CCR");
}
/********************************************************************/
static void
mac8 (int index, uint16 opword)
{
/* MOVE.L <ea>,MASK */
append_size(dstr,opword,13,TRUE);
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",MASK");
}
/********************************************************************/
static void
mac9 (int index, uint16 opword)
{
/* MOVE.L MASK,Rx */
(void)index;
append_size(dstr,opword,13,TRUE);
append_string(dstr,"MASK,");
append_register(dstr,opword,3,2);
}
/********************************************************************/
#endif /* CPU_MCF_MAC */
#ifdef CPU_MCF5407
/********************************************************************/
static void
func64 (int index, uint16 opword)
{
(void)index;
/* INTOUCH */
append_register(dstr,opword,3,2);
}
/********************************************************************/
static void
func65 (int index, uint16 opword)
{
/* MOV3Q */
int data;
data = ((opword & 0x0E00) >> 9);
append_size(dstr,opword,13,TRUE);
append_string(dstr,"#");
if (data == 0)
append_string(dstr,"-1");
else
append_value(dstr,data,8);
append_string(dstr,",");
append_ea(dstr,opword,5,isa[index].ea_mask);
}
/********************************************************************/
static void
func66 (int index, uint16 opword)
{
/* MVS MVZ */
append_size(dstr,(opword & 0x40),7,TRUE);
append_ea(dstr,opword,5,isa[index].ea_mask);
append_string(dstr,",");
append_register(dstr,opword,15,11);
}
/********************************************************************/
static void
func67 (int index, uint16 opword)
{
/* TAS*/
disasm_op_size = SIZE_BYTE;
append_instruction(dstr,"TAS.B");
append_ea(dstr,opword,5,isa[index].ea_mask);
}
/********************************************************************/
#endif /*CPU_MCF5407 */
#include "src/cpu/coldfire/mcf5xxx/itable.h"
/********************************************************************/
static void
disasm_display (char *stmt, ADDRESS init_pc, ADDRESS next_pc)
{
int nw, ad, done, i, spaces;
ADDRESS pc;
#if (defined(SYMBOL_TABLE))
char sstr[100];
#endif
pc = init_pc;
ad = FALSE;
done = FALSE;
#if (defined(SYMBOL_TABLE))
if (symtab_convert_address(pc,sstr))
{
printf("%08X:\n%08X: %s:\n",
(unsigned int)pc,
(unsigned int)pc,
sstr);
}
#endif
while (!done)
{
nw = 0;
printf("%08lX: ",(unsigned long)pc);
spaces = 10; /* used 10 chars up so far on screen */
while (pc < next_pc)
{
printf("%04X ",cpu_read_data((ADDRESS)pc,16));
pc = (ADDRESS)((unsigned int)pc + (unsigned int)2);
spaces += 5;
if (++nw >= 4)
{
break;
}
}
if (!ad)
{
for (i = spaces; i < 31; i++)
printf(" ");
printf("%s",stmt);
ad = TRUE;
}
printf("\n");
if (pc >= next_pc)
done = TRUE;
}
}
/********************************************************************/
ADDRESS
cpu_disasm (ADDRESS init_pc, int display)
{
/*
* This routine disassembles one ColdFire instruction, and
* returns the address of the next instruction.
*/
int index;
uint16 opword;
disasm_pc = init_pc;
opword = (uint16)cpu_read_data((ADDRESS)disasm_pc,16);
valid_instruction = FALSE;
dstr[0] = '\0';
for (index = 0; index < ISASIZE; index++)
{
if ((opword & isa[index].keepers) == isa[index].match)
{
valid_instruction = TRUE;
append_instruction(dstr,isa[index].instruction);
inc_disasm_pc(2);
isa[index].handler(index,opword); /* disassemble */
break;
}
}
if (valid_instruction)
{
}
else
{
append_instruction(dstr,"DC.W");
append_value(dstr,opword,16);
/* inc_disasm_pc(2); */
disasm_pc = init_pc + 2;
}
if (display)
{
disasm_display(dstr,init_pc,disasm_pc);
}
return disasm_pc;
}
/********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -