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

📄 mpc.c

📁 Coldfire MCF5282 DBug bootloader
💻 C
📖 第 1 页 / 共 5 页
字号:
	 */

	char *rAs, *rBs;
	int rA, rB;

	if (parse_args(&rAs,&rBs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((rA = gpr_value(rAs)) < 0)
		return FALSE;

	if ((rB = gpr_value(rBs)) < 0)
		return FALSE;

	asm_insn |= (rA << rAshift);
	asm_insn |= (rB << rBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_rD_rB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rD,rB (rD bits 6-10, rB bits 16-20)
	 * insn rS,rB (rS bits 6-10, rB bits 16-20)
	 */

	char *rDs, *rBs;
	int rD, rB;

	if (parse_args(&rDs,&rBs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((rD = gpr_value(rDs)) < 0)
		return FALSE;

	if ((rB = gpr_value(rBs)) < 0)
		return FALSE;

	asm_insn |= (rD << rDshift);
	asm_insn |= (rB << rBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_frA_frB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,frA,frB (frD bits 6-10, frA bits 11-15, frB bits 16-20)
	 */

	char *frDs, *frAs, *frBs;
	int frD, frA, frB;

	if (parse_args(&frDs,&frAs,&frBs,NULL,NULL) != 3)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((frA = fpr_value(frAs)) < 0)
		return FALSE;

	if ((frB = fpr_value(frBs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (frA << frAshift);
	asm_insn |= (frB << frBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_frB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,frB (frD bits 6-10, frB bits 16-20)
	 */

	char *frDs, *frBs;
	int frD, frB;

	if (parse_args(&frDs,&frBs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((frB = fpr_value(frBs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (frB << frBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_crfD_frA_frB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn crfD,frA,frB
	 */
	char *crfDs, *frAs, *frBs;
	int crfD, frA, frB;

	if (parse_args(&crfDs,&frAs,&frBs,NULL,NULL) != 3)
		return FALSE;

	if ((crfD = crf_value(crfDs)) < 0)
		return FALSE;

	if ((frA = fpr_value(frAs)) < 0)
		return FALSE;

	if ((frB = fpr_value(frBs)) < 0)
		return FALSE;

	asm_insn |= (crfD << crfDshift);
	asm_insn |= (frA  << frAshift);
	asm_insn |= (frB  << frBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_frA_frC_frB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,frA,frC,frB
	 */

	char *frDs, *frAs, *frCs, *frBs;
	int frD, frA, frC, frB;

	if (parse_args(&frDs,&frAs,&frCs,&frBs,NULL) != 4)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((frA = fpr_value(frAs)) < 0)
		return FALSE;

	if ((frC = fpr_value(frCs)) < 0)
		return FALSE;

	if ((frB = fpr_value(frBs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (frA << frAshift);
	asm_insn |= (frC << frCshift);
	asm_insn |= (frB << frBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_frA_frC (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,frA,frC
	 */

	char *frDs, *frAs, *frCs;
	int frD, frA, frC;

	if (parse_args(&frDs,&frAs,&frCs,NULL,NULL) != 3)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((frA = fpr_value(frAs)) < 0)
		return FALSE;

	if ((frC = fpr_value(frCs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (frA << frAshift);
	asm_insn |= (frC << frCshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_rD_d_rA (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rD,d(rA)
	 */
	char *rDs, *ds, *rAs, *drAs, *p;
	int rD, rA;
	uint32 value;

	if (parse_args(&rDs,&drAs,NULL,NULL,NULL) != 2)
		return FALSE;

	if (parse_offset(drAs, &ds, &rAs) < 0)
		return FALSE;

	if ((rD = gpr_value(rDs)) < 0)
		return FALSE;

	if ((rA = gpr_value(rAs)) < 0)
		return FALSE;

	value = strtoul(ds,&p,0);
	if ((value == 0) && (p == ds))
		return FALSE;

	asm_insn |= (rD << rDshift);
	asm_insn |= (rA << rAshift);
	asm_insn |= (value & 0x0000FFFF);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_d_rA (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,d(rA)
	 * insn frS,d(rA)
	 */
	char *frDs, *ds, *rAs, *drAs, *p;
	int frD, rA;
	uint32 value;

	if (parse_args(&frDs,&drAs,NULL,NULL,NULL) != 2)
		return FALSE;

	if (parse_offset(drAs, &ds, &rAs) < 0)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((rA = gpr_value(rAs)) < 0)
		return FALSE;

	value = strtoul(ds,&p,0);
	if ((value == 0) && (p == ds))
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (rA << rAshift);
	asm_insn |= (value & 0x0000FFFF);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD_rA_rB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD,rA,rB
	 * insn frS,rA,rB
	 */
	char *frDs, *rAs, *rBs;
	int frD, rA, rB;

	if (parse_args(&frDs,&rAs,&rBs,NULL,NULL) != 3)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	if ((rA = gpr_value(rAs)) < 0)
		return FALSE;

	if ((rB = gpr_value(rBs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);
	asm_insn |= (rA << rAshift);
	asm_insn |= (rB << rBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_crfD_crfS (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn crfD,crfS
	 */
	char *crfDs, *crfSs;
	int crfD, crfS;

	if (parse_args(&crfDs,&crfSs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((crfD = crf_value(crfDs)) < 0)
		return FALSE;

	if ((crfS = crf_value(crfSs)) < 0)
		return FALSE;

	asm_insn |= (crfD << crfDshift);
	asm_insn |= (crfS << crfSshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_crfD (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn crfD
	 */

	char *crfDs;
	int crfD;

	if (parse_args(&crfDs,NULL,NULL,NULL,NULL) != 1)
		return FALSE;

	if ((crfD = crf_value(crfDs)) < 0)
		return FALSE;

	asm_insn |= (crfD << crfDshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_rD (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rD
	 * insn rS
	 */
	char *rDs;
	int rD;

	if (parse_args(&rDs,NULL,NULL,NULL,NULL) != 1)
		return FALSE;

	if ((rD = gpr_value(rDs)) < 0)
		return FALSE;

	asm_insn |= (rD << rDshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_rB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rB
	 */
	char *rBs;
	int rB;

	if (parse_args(&rBs,NULL,NULL,NULL,NULL) != 1)
		return FALSE;

	if ((rB = gpr_value(rBs)) < 0)
		return FALSE;

	asm_insn |= (rB << rBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_frD (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn frD
	 */
	char *frDs;
	int frD;

	if (parse_args(&frDs,NULL,NULL,NULL,NULL) != 1)
		return FALSE;

	if ((frD = fpr_value(frDs)) < 0)
		return FALSE;

	asm_insn |= (frD << frDshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_mxspr (char *rDs, char *SPRs)
{
	char *p;
	int rD, SPR;

	if ((rD = gpr_value(rDs)) < 0)
		return FALSE;

	/* FIX !!! Allow symbol SPR name */
	SPR = strtoul(SPRs, &p, 10);
	if ((SPR == 0) && (p == SPRs))
		return FALSE;
	if ((SPR < 0) || (SPR > 1023))
		return FALSE;

	asm_insn |= (rD << rDshift);
	asm_insn |= ((SPR & 0x001F) << 16);
	asm_insn |= ((SPR & 0x03E0) << (11-5));

	return TRUE;
}

/********************************************************************/
static int
afunc_rD_SPR (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rD,SPR
	 * insn rD,TBR
	 */
	char *rDs, *SPRs;

	if (parse_args(&rDs,&SPRs,NULL,NULL,NULL) != 2)
		return FALSE;

	return afunc_mxspr(rDs,SPRs);
}

/********************************************************************/
static int
afunc_SPR_rS (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn SPR,rS
	 */
	char *rSs, *SPRs;

	if (parse_args(&SPRs,&rSs,NULL,NULL,NULL) != 2)
		return FALSE;

	return afunc_mxspr(rSs,SPRs);
}

/********************************************************************/
static int
afunc_mxsr (char *rDs, char *SRs)
{
	int rD, SR;

	if ((rD = gpr_value(rDs)) < 0)
		return FALSE;

	if ((SR = sr_value(SRs)) < 0)
		return FALSE;

	asm_insn |= (rD << rDshift);
	asm_insn |= (SR << SRshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_rD_SR (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn rD,SR
	 */
	char *rDs, *SRs;

	if (parse_args(&rDs,&SRs,NULL,NULL,NULL) != 2)
		return FALSE;

	return afunc_mxsr(rDs,SRs);
}

/********************************************************************/
static int
afunc_SR_rS (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn SR,rS
	 */
	char *rSs, *SRs;

	if (parse_args(&SRs,&rSs,NULL,NULL,NULL) != 2)
		return FALSE;

	return afunc_mxsr(rSs,SRs);
}

/********************************************************************/
static int
afunc_CRM_rS (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn CRM,rS
	 */
	char *rSs, *CRMs;
	int rS, CRM;

	if (parse_args(&CRMs,&rSs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((rS = gpr_value(rSs)) < 0)
		return FALSE;

	if ((CRM = eightbit_value(CRMs)) < 0)
		return FALSE;

	asm_insn |= (rS << rSshift);
	asm_insn |= (CRM << 12);

	return TRUE;
}

/********************************************************************/
static int
afunc_crbD (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn crbD
	 */
	char *crbDs;
	int crbD;

	if (parse_args(&crbDs,NULL,NULL,NULL,NULL) != 1)
		return FALSE;

	if ((crbD = crb_value(crbDs)) < 0)
		return FALSE;

	asm_insn |= (crbD << crbDshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_FM_frB (void)
{
	/*
	 * This works for instructions with the following formats:
	 *
	 * insn FM,frB
	 */

	char *FMs, *frBs;
	int FM, frB;

	if (parse_args(&FMs,&frBs,NULL,NULL,NULL) != 2)
		return FALSE;

	if ((FM = eightbit_value(FMs)) < 0)
		return FALSE;

	if ((frB = fpr_value(frBs)) < 0)
		return FALSE;

	asm_insn |= (FM << 17);
	asm_insn |= (frB << frBshift);

	return TRUE;
}

/********************************************************************/
static int
afunc_crfD_IMM (void)
{
	/*
	 * This works for in

⌨️ 快捷键说明

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