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

📄 dis_cf.c

📁 umon bootloader source code, support mips cpu.
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		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);
	}
}

static void
func56 (int index, WORD opword)
{
	/* EXG.L */

	(void)index;

	switch (opword & 0x00F8)
	{
		case 0x0040:
			append_register(dstr,opword,DATA_REGISTER,11);
			append_string(dstr,",");
			append_register(dstr,opword,DATA_REGISTER,2);
			break;
		case 0x0048:
			append_register(dstr,opword,ADDRESS_REGISTER,11);
			append_string(dstr,",");
			append_register(dstr,opword,ADDRESS_REGISTER,2);
			break;
		case 0x0088:
			append_register(dstr,opword,DATA_REGISTER,11);
			append_string(dstr,",");
			append_register(dstr,opword,ADDRESS_REGISTER,2);
			break;
		default:
			valid_instruction = FALSE;
	}
}

static void
func57 (int index, WORD opword)
{
	/* PACK UNPK -(Ax),-(Ay),#<adj> */
	int adj;

	(void)index;

	adj = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	append_string(dstr,"-(");
	append_register(dstr,opword,ADDRESS_REGISTER,2);
	append_string(dstr,"),-(");
	append_register(dstr,opword,ADDRESS_REGISTER,11);
	append_string(dstr,"),#");
	append_value(dstr,adj,SIZE_WORD);
}

static void
func58 (int index, WORD opword)
{
	/* PACK UNPK Dx,Dy,#<adj> */
	int adj;

	(void)index;

	adj = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	append_register(dstr,opword,DATA_REGISTER,2);
	append_string(dstr,",");
	append_register(dstr,opword,DATA_REGISTER,11);
	append_string(dstr,",#");
	append_value(dstr,adj,SIZE_WORD);
}

static void
func59 (int index, WORD opword)
{
	/* TRAPcc .W .L #<data> */
	int data;

	(void)index;

	if (opword & 0x0001)
	{
		/* long */
		data = cpu_read_data((ADDRESS)disasm_pc,SIZE_LONG);
		inc_disasm_pc(4);
		append_size(dstr,0x0002,1,TRUE);
		append_string(dstr,"#");
		append_value(dstr,data,SIZE_LONG);
	}
	else
	{
		/* word */
		data = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
		inc_disasm_pc(2);
		append_size(dstr,0x0002,2,TRUE);
		append_string(dstr,"#");
		append_value(dstr,data,SIZE_WORD);
	}
}

static void
func60 (int index, WORD opword)
{
	/* MOVE to USP */

	(void)index;

	append_register(dstr,opword,ADDRESS_REGISTER,2);
	append_string(dstr,",USP");
}

static void
func61 (int index, WORD opword)
{
	/* MOVE from USP */

	(void)index;

	append_string(dstr,"USP,");
	append_register(dstr,opword,ADDRESS_REGISTER,2);
}
#endif /* MCF5200 */

#ifdef CPU32
static void
func62 (int index, WORD opword)
{
	/* TBL */
	int opword2;

	opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	switch (opword2 & 0x0C00)
	{
		case 0x0000:
			append_instruction(dstr,"TBLU");
			break;
		case 0x0400:
			append_instruction(dstr,"TBLUN");
			break;
		case 0x0800:
			append_instruction(dstr,"TBLS");
			break;
		case 0x0C00:
			append_instruction(dstr,"TBLSN");
			break;
	}
	append_size(dstr,opword2,7,TRUE);

	if ((opword & 0x0038) == 0)
	{
		/* TBL Dym:Dyn,Dx */
		append_register(dstr,opword,DATA_REGISTER,2);
		append_string(dstr,":");
		append_register(dstr,opword2,DATA_REGISTER,2);
		append_string(dstr,",");
		append_register(dstr,opword2,DATA_REGISTER,14);
	}
	else
	{
		/* TBL <ea>,Dx */
		append_ea(dstr,opword,5,isa[index].ea_mask);
		append_string(dstr,",");
		append_register(dstr,opword2,DATA_REGISTER,14);
	}
}

static void
func63 (int index, WORD opword)
{
	/* LPSTOP */
	int opword2, data;

	opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	if (opword == 0x01C0)
	{
		data = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
		inc_disasm_pc(2);

		append_string(dstr,"#");
		append_value(dstr,data,SIZE_WORD);
	}
	else
	{
		/* this opcode matches TBL as well, check it */
		disasm_pc = disasm_pc - 2;
		func62(index,opword);
	}
}
#endif /* CPU32 */

/*************************************************************/
#ifdef MCF5200M

static void
mac1 (int index, WORD opword)
{
	/* MAC.W Rw,Rx */
	/* MAC.L Rw,Rx */
	/* MSAC.W Rw,Rx */
	/* MSAC.L Rw,Rx */
	int opword2;

	opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	if (opword2 & 0x0100)
	{
		if (opword2 & 0x0100)
			append_instruction(dstr,"MSAC.L");
		else
			append_instruction(dstr,"MSAC.W");
	}
	else
	{
		if (opword2 & 0x0100)
			append_instruction(dstr,"MAC.L");
		else
			append_instruction(dstr,"MAC.W");
	}

	append_register(dstr,opword,6,11);	/* Rw */
	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,",<<");
	else if ((opword2 & 0x0600) == 0x0600)
		append_string(dstr,",>>");
}

static void
mac2 (int index, WORD opword)
{
	/* MACL.W Rw,Rx */
	/* MACL.L Rw,Rx */
	/* MSACL.W Rw,Rx */
	/* MSACL.L Rw,Rx */
	int opword2;

	opword2 = cpu_read_data((ADDRESS)disasm_pc,SIZE_WORD);
	inc_disasm_pc(2);

	if (opword2 & 0x0100)
	{
		if (opword2 & 0x0100)
			append_instruction(dstr,"MSACL.L");
		else
			append_instruction(dstr,"MSACL.W");
	}
	else
	{
		if (opword2 & 0x0100)
			append_instruction(dstr,"MACL.L");
		else
			append_instruction(dstr,"MACL.W");
	}

	append_register(dstr,opword2,15,14);	/* Rw */
	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,"<<,");
	else if ((opword2 & 0x0600) == 0x0600)
		append_string(dstr,">>,");

	append_ea(dstr,opword,5,isa[index].ea_mask);
	append_string(dstr,",");

	append_register(dstr,opword,6,11);	/* Ry */
}

static void
mac3 (int index, WORD opword)
{
	/* MOVE.L <ea>,ACC */
	append_ea(dstr,opword,5,isa[index].ea_mask);
	append_string(dstr,",ACC,");
}

static void
mac4 (int index, WORD opword)
{
	/* MOVE.L <ea>,MACSR */
	append_ea(dstr,opword,5,isa[index].ea_mask);
	append_string(dstr,",MACSR,");
}

static void
mac5 (int index, WORD opword)
{
	/* MOVE.L ACC,Rx */
	append_string(dstr,"ACC,");
	append_register(dstr,opword,3,2);
}

static void
mac6 (int index, WORD opword)
{
	/* MOVE.L MACSR,Rx */
	append_string(dstr,"MACSR,");
	append_register(dstr,opword,3,2);
}

static void
mac7 (int index, WORD opword)
{
	/* MOVE.L MACSR,CCR */
	append_string(dstr,"MACSR,CCR");
}

#endif /* MCF5200M */
/*************************************************************/

static const INSTRENTRY isa[] = {

/* LINE 0000 */
#ifndef MCF5200
{0xFFFF,0x003C,"ORI.B",	EA_NONE,func2},	/* ORI.B #<data>,CCR */
{0xFFFF,0x007C,"ORI.W",	EA_NONE,func3},	/* ORI.W #<data>,SR */
{0xFFFF,0x023C,"ANDI.B",EA_NONE,func2},	/* ANDI.B #<data>,CCR */
{0xFFFF,0x027C,"ANDI.B",EA_NONE,func3},	/* ANDI.W #<data>,SR */
{0xFFFF,0x0A3C,"EORI.B",EA_NONE,func2},	/* EORI.B #<data>,CCR */
{0xFFFF,0x0A7C,"EORI.W",EA_NONE,func3},	/* EORI.W #<data>,SR */
{0xFFFF,0x0CFC,"CAS2",	EA_NONE,func40}, /*CAS2.W Dc1:Dc2,Du1,Du2,(Rn1):(Rn2)*/
{0xFFFF,0x0EFC,"CAS2",	EA_NONE,func40}, /*CAS2.L Dc1:Dc2,Du1,Du2,(Rn1):(Rn2)*/
{0xFFF0,0x06C0,"RTM",	EA_NONE,func4},	/* RTM Rn */
#endif
#ifndef MCF5200
{0xFFC0,0x0000,"ORI",	EA_DATALT1,func6},	/* ORI.B #<data>,<ea> */
{0xFFC0,0x0040,"ORI",	EA_DATALT1,func6},	/* ORI.W #<data>,<ea> */
{0xFFC0,0x0080,"ORI",	EA_DATALT1,func6},	/* ORI.L #<data>,<ea> */
#else
{0xFFF8,0x0080,"ORI",	DRD,func6},	/* ORI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x0200,"ANDI",	EA_DATALT1,func6},	/* ANDI.B #<data>,<ea> */
{0xFFC0,0x0240,"ANDI",	EA_DATALT1,func6},	/* ANDI.W #<data>,<ea> */
{0xFFC0,0x0280,"ANDI",	EA_DATALT1,func6},	/* ANDI.L #<data>,<ea> */
#else
{0xFFF8,0x0280,"ANDI",	DRD,func6},	/* ANDI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x0400,"SUBI",	EA_DATALT1,func6},	/* SUBI.B #<data>,<ea> */
{0xFFC0,0x0440,"SUBI",	EA_DATALT1,func6},	/* SUBI.W #<data>,<ea> */
{0xFFC0,0x0480,"SUBI",	EA_DATALT1,func6},	/* SUBI.L #<data>,<ea> */
#else
{0xFFF8,0x0480,"SUBI",	DRD,func6},	/* SUBI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x0600,"ADDI",	EA_DATALT1,func6},	/* ADDI.B #<data>,<ea> */
{0xFFC0,0x0640,"ADDI",	EA_DATALT1,func6},	/* ADDI.W #<data>,<ea> */
{0xFFC0,0x0680,"ADDI",	EA_DATALT1,func6},	/* ADDI.L #<data>,<ea> */
#else
{0xFFF8,0x0680,"ADDI",	DRD,func6},	/* ADDI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x06C0,"CALLM",	EA_CONTROL,func5},	/* CALLM #<data>,<ea> */
{0xFFC0,0x00C0,"CMP2",	EA_CONTROL,func19},	/* CMP2.B <ea>,Rn */
{0xFFC0,0x02C0,"CMP2",	EA_CONTROL,func19},	/* CMP2.W <ea>,Rn */
{0xFFC0,0x04C0,"CMP2",	EA_CONTROL,func19},	/* CMP2.L <ea>,Rn */
#endif
#ifndef MCF5200
{0xFFC0,0x0A00,"EORI",	EA_DATALT1,func6},	/* EORI.B #<data>,<ea> */
{0xFFC0,0x0A40,"EORI",	EA_DATALT1,func6},	/* EORI.W #<data>,<ea> */
{0xFFC0,0x0A80,"EORI",	EA_DATALT1,func6},	/* EORI.L #<data>,<ea> */
#else
{0xFFF8,0x0A80,"EORI",	DRD,func6},	/* EORI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x0C00,"CMPI",	EA_DATA1,func6},	/* CMPI.B #<data>,<ea> */
{0xFFC0,0x0C40,"CMPI",	EA_DATA1,func6},	/* CMPI.W #<data>,<ea> */
{0xFFC0,0x0C80,"CMPI",	EA_DATA1,func6},	/* CMPI.L #<data>,<ea> */
#else
{0xFFF8,0x0C80,"CMPI",	DRD,func6},	/* CMPI.L #<data>,Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x0800,"BTST",	EA_DATA1,func1},	/* BTST #<data>,<ea> */
{0xFFC0,0x0840,"BCHG",	EA_DATALT1,func1},	/* BCHG #<data>,<ea> */
{0xFFC0,0x08C0,"BSET",	EA_DATALT1,func1},	/* BSET #<data>,<ea> */
{0xFFC0,0x0880,"BCLR",	EA_DATALT1,func1},	/* BCLR #<data>,<ea> */
#else
{0xFFC0,0x0800,"BTST",	EA_DATA1,func1},	/* BTST #<data>,<ea> */
{0xFFC0,0x0840,"BCHG",	EA_DATA1,func1},	/* BCHG #<data>,<ea> */
{0xFFC0,0x08C0,"BSET",	EA_DATA1,func1},	/* BSET #<data>,<ea> */
{0xFFC0,0x0880,"BCLR",	EA_DATA1,func1},	/* BCLR #<data>,<ea> */
#endif
#ifndef MCF5200
{0xFFC0,0x0E00,"MOVES",	EA_MEMALT1,func30},
{0xFFC0,0x0E40,"MOVES",	EA_MEMALT1,func30},
{0xFFC0,0x0E80,"MOVES",	EA_MEMALT1,func30},
{0xFFC0,0x0AC0,"CAS",	EA_MEMALT1,func41},	/* CAS.B Dc,Du,<ea> */
{0xFFC0,0x0CC0,"CAS",	EA_MEMALT1,func41},	/* CAS.W Dc,Du,<ea> */
{0xFFC0,0x0EC0,"CAS",	EA_MEMALT1,func41},	/* CAS.L Dc,Du,<ea> */
{0xF1F8,0x0108,"MOVEP",	EA_NONE,func42},	/* MOVEP.W (d16,Ay),Dx */
{0xF1F8,0x0148,"MOVEP",	EA_NONE,func42},	/* MOVEP.L (d16,Ay),Dx */
{0xF1F8,0x0188,"MOVEP",	EA_NONE,func42},	/* MOVEP.W Dx,(d16,Ay) */
{0xF1F8,0x01C8,"MOVEP",	EA_NONE,func42},	/* MOVEP.L Dx,(d16,Ay) */
#endif
{0xF1C0,0x0100,"BTST",	EA_DATA,func7},		/* BTST Dn,<ea> */
{0xF1C0,0x0140,"BCHG",	EA_DATALT1,func7},	/* BCHG Dn,<ea> */
{0xF1C0,0x01C0,"BSET",	EA_DATALT1,func7},	/* BSET Dn,<ea> */
{0xF1C0,0x0180,"BCLR",	EA_DATALT1,func7},	/* BCLR Dn,<ea> */





/* LINE 0001 */
#ifndef MCF5200
{0xF000,0x1000,"MOVE",	EA_DATALT1 /* dest <ea> */,func8},	/* MOVE.B */
#else
{0xF000,0x1000,"MOVE",	EA_ALL /* dest <ea> */,func8},	/* MOVE.B */
#endif





/* LINE 0010 */
{0xF1C0,0x2040,"MOVEA",	EA_ALL,func26},	/* MOVEA.L */
#ifndef MCF5200
{0xF000,0x2000,"MOVE",	EA_DATALT1 /* dest <ea> */,func8},	/* MOVE.L */
#else
{0xF000,0x2000,"MOVE",	EA_ALL /* dest <ea> */,func8},	/* MOVE.L */
#endif





/* LINE 0011 */
{0xF1C0,0x3040,"MOVEA",	EA_ALL,func26},	/* MOVEA.W */
#ifndef MCF5200
{0xF000,0x3000,"MOVE",	EA_DATALT1 /* dest <ea> */,func8},	/* MOVE.W */
#else
{0xF000,0x3000,"MOVE",	EA_ALL /* dest <ea> */,func8},	/* MOVE.W */
#endif





/* LINE 0100 */
{0xFFFF,0x4AFC,"ILLEGAL",EA_NONE,func17},
{0xFFFF,0x4E71,"NOP",	EA_NONE,func17},
{0xFFFF,0x4AC8,"HALT",	EA_NONE,func17},
{0xFFFF,0x4BCC,"PULSE",	EA_NONE,func17},
#ifndef MCF5200
{0xFFFF,0x4E74,"RTD",	EA_NONE,func23},
{0xFFFF,0x4E77,"RTR",	EA_NONE,func17},
#endif
{0xFFFF,0x4E75,"RTS",	EA_NONE,func17},
#ifndef MCF5200
{0xFFFF,0x4E76,"TRAPV",	EA_NONE,func17},
{0xFFFF,0x4AFA,"BGND",	EA_NONE,func17},
{0xFFFF,0x4E70,"RESET",	EA_NONE,func17},
#endif
{0xFFFF,0x4E72,"STOP",	EA_NONE,func23},
{0xFFFF,0x4E73,"RTE",	EA_NONE,func17},
{0xFFFF,0x4E7A,"MOVEC",	EA_NONE,func36},
{0xFFFF,0x4E7B,"MOVEC",	EA_NONE,func36},
{0xFFF8,0x4880,"EXT.W",	EA_NONE,func13},	/* EXT.W Dn */
{0xFFF8,0x48C0,"EXT.L",	EA_NONE,func13},	/* EXT.L Dn */
{0xFFF8,0x49C0,"EXTB.L",EA_NONE,func13},	/* EXTB.L Dn */
#ifndef MCF5200
{0xFFF8,0x4808,"LINK.L",EA_NONE,func43},	/* LINK.L An,#<disp>*/
#endif
{0xFFF8,0x4840,"SWAP",	EA_NONE,func13},	/* SWAP.W Dn */
#ifndef MCF5200
{0xFFF8,0x4848,"BKPT",	EA_NONE,func44},	/* BKPT #<data> */
#endif
{0xFFF8,0x4E58,"UNLK",	EA_NONE,func21},	/* UNLK An */
{0xFFF8,0x4E50,"LINK",	EA_NONE,func16},	/* LINK.W An,#<disp>*/
#ifndef MCF5200
{0xFFF8,0x4E60,"MOVE",	EA_NONE,func60},	/* MOVE An,USP */
{0xFFF8,0x4E68,"MOVE",	EA_NONE,func61},	/* MOVE USP,An */
#endif
#ifndef MCF5200
{0xFFC0,0x40C0,"MOVE",	EA_DATALT1,func9},		/* MOVE.W SR,<ea> */
{0xFFC0,0x42C0,"MOVE",	EA_DATALT2,func11},		/* MOVE.B CCR,<ea> */
#else
{0xFFF8,0x40C0,"MOVE",	DRD,func9},			/* MOVE.W SR,<ea> */
{0xFFF8,0x42C0,"MOVE",	DRD,func11},		/* MOVE.B CCR,<ea> */
#endif
#ifndef MCF5200
{0xFFC0,0x4000,"NEGX",	EA_DATALT1,func15},	/* NEGX.B <ea> */
{0xFFC0,0x4040,"NEGX",	EA_DATALT1,func15},	/* NEGX.W <ea> */
{0xFFC0,0x4080,"NEGX",	EA_DATALT1,func15},	/* NEGX.L <ea> */
#else
{0xFFF8,0x4080,"NEGX",	DRD,func15},	/* NEGX.L Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x4400,"NEG",	EA_DATALT1,func15},		/* NEG.B <ea> */
{0xFFC0,0x4440,"NEG",	EA_DATALT1,func15},		/* NEG.W <ea> */
{0xFFC0,0x4480,"NEG",	EA_DATALT1,func15},		/* NEG.L <ea> */
#else
{0xFFF8,0x4480,"NEG",	DRD,func15},		/* NEG.L Dn */
#endif
#ifndef MCF5200
{0xFFC0,0x4600,"NOT",	EA_DATALT1,func15},		/* NOT.B <ea> */
{0xFFC0,0x4640,"NOT",	EA_DATALT1,func15},		/* NOT.W <ea> */
{0xFFC0,0x4680,"NOT",	EA_DATALT1,func15},		/* NOT.L <ea> */
#else
{0xFFF8,0x4680,"NOT",	DRD,func15},		/* NOT.L Dn */
#endif
{0xFFF0,0x4E40,"TRAP",	EA_NONE,func22},	/* TRAP #<vector> */
#ifndef MCF5200
{0xFFC0,0x46C0,"MOVE",	EA_DATA,func10},		/* MOVE to SR */
#else
{0xFFC0,0x46C0,"MOVE",	(DRD | IM),func10},		/* MOVE to SR */
#endif
{0xFFC0,0x4200,"CLR",	EA_DATALT1,func15},		/* CLR.B <ea> */
{0xFFC0,0x4240,"CLR",	EA_DATALT1,func15},		/* CLR.W <ea> */
{0xFFC0,0x4280,"CLR",	EA_DATALT1,func15},		/* CLR.L <ea> */
#ifndef MCF5200
{0xFFC0,0x44C0,"MOVE",	EA_DATA,func12},		/* MOVE.B <ea>,CCR */
#else
{0xFFC0,0x44C0,"MOVE",	(DRD | IM),func12},		/* MOVE.B <ea>,CCR */
#endif
#ifndef MCF5200
{0xFFC0,0x4800,"NBCD",	EA_DATALT1,func18},		/* NBCD.B <ea> */
#endif
{0xFFC0,0x4840,"PEA",	EA_CONTROL,func18},		/* PEA <ea> */
#ifndef MCF5200
{0xFFC0,0x4AC0,"TAS",	EA_DATALT1,func18},	/* TAS.B <ea> */
#endif
{0xFFC0,0x4A00,"TST"	,EA_ALL,func15},		/* TST.B <ea> */
{0xFFC0,0x4A40,"TST"	,EA_ALL,func15},		/* TST.W <ea> */
{0xFFC0,0x4A80,"TST"	,EA_ALL,func15},		/* TST.L <ea> */
#ifndef MCF5200
{0xFFC0,0x4C00,"MULS"	,EA_DATA,func39},		/* MULS.L */
#else
{0xFFC0,0x4C00,"MULS"	,(DRD|ARI|ARIPO|ARIPR|ARID|ARII8),func39}, /* MULS.L */
#endif
#if 0
{0xFFC0,0x4C00,"MULU"	,EA_DATA,func39},		/*

⌨️ 快捷键说明

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