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

📄 dis_68k.c

📁 umon bootloader source code, support mips cpu.
💻 C
📖 第 1 页 / 共 3 页
字号:
		if (BIT15(cur2bytes))
			strcat(mneu,"-");
	}
	strcat(mneu,conv_temp);
}	/* bcc_bsr_bra() */



void
moveq()
{
	/*
		if (BIT8(cur2bytes))
			confused();
	*/
	strcpy(mneu,"movq.l  &");
	if (BIT7(cur2bytes))
		strcat(mneu,"-");
	convert(BIT7(cur2bytes) ? 
	    -(short) (LOW8(cur2bytes) | 0xff00) : 
	    LOW8(cur2bytes), conv_temp,LEAD);
	strcat(mneu,conv_temp);
	sprintf(conv_temp,",%%d%d",BITS11_9(cur2bytes));
	strcat(mneu,conv_temp);
}	/* moveq() */

void
or_div_sbcd()
{
	if (BITS7_6(cur2bytes) == 3) {	/* divide */
		strcat(mneu,"div_.w  ");
		if (BIT8(cur2bytes))
			mneu[3] = 's';
			else
			mneu[3] = 'u';
		sprintf(mneu,"%s%s,%%d%d",mneu,
		    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),WORD,
		    BIT8(cur2bytes) ? SIGNED : UNSIGNED),
		    BITS11_9(curinstr));
	}
	else if (BITS8_6(cur2bytes) == 4 && BITS5_4(cur2bytes) == 0) {
		/* sbcd */
		if (BIT3(cur2bytes))
			sprintf(mneu,"sbcd.b  -(%s),-(%s)",
			    addregs[BITS2_0(cur2bytes)],
			    addregs[BITS11_9(cur2bytes)]);
			else
			sprintf(mneu,"sbcd.b  %%d%d,%%d%d",
			    BITS2_0(cur2bytes),BITS11_9(cur2bytes));
	}
	else {				/* or */
		unsigned short inst = cur2bytes;	/* remember inst. */
		char operand[32];

		strcat(mneu,"or._    ");
		mneu[3] = size[BITS7_6(inst)];
		operand[0] = '\0';
		strcat(operand, eff_add(BITS5_3(inst),BITS2_0(inst),
		    BITS7_6(inst)+1,UNSIGNED));
		if (!BIT8(inst))
			sprintf(mneu, "%s%s,",mneu,operand);
		sprintf(mneu,"%s%%d%d",mneu,BITS11_9(inst));
		if (BIT8(inst))
			sprintf(mneu, "%s,%s",mneu,operand);
	}
}

void
sub_subx()
{
	if (BITS7_6(cur2bytes) == 3) {	/* suba */
		strcat(mneu,"suba._  ");
		mneu[5] = BIT8(cur2bytes) ? 'l' : 'w';
		sprintf(mneu,"%s%s,%s",mneu,
		    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
		    BIT8(cur2bytes) ? LONG : WORD,NOTSIGNED),
		    addregs[BITS11_9(curinstr)]);
	}
	else if (BIT8(cur2bytes) && !BITS5_4(cur2bytes)) { /* subx */
		strcat(mneu,"subx._  ");
		mneu[5] = size[BITS7_6(cur2bytes)];
		if (BIT3(cur2bytes))
			sprintf (mneu,"%s-(%s),-(%s)",mneu,
			    addregs[BITS2_0(cur2bytes)],
			    addregs[BITS11_9(cur2bytes)]);
		else 
			sprintf(mneu,"%s%%d%d,%%d%d",mneu,BITS2_0(cur2bytes),
			    BITS11_9(cur2bytes));
	}
	else {				/* sub */
		strcat(mneu,"sub._   ");
		mneu[4] = size[BITS7_6(cur2bytes)];
		if (BIT8(cur2bytes))
			sprintf(mneu,"%s%%d%d,%s",mneu,BITS11_9(curinstr),
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    NULL,NULL));
			else
			sprintf(mneu,"%s%s,%%d%d",mneu,
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    BITS7_6(cur2bytes) + 1,UNSIGNED),
			    BITS11_9(curinstr));
	}
}

void
cmp_eor()
{
	if (BITS7_6(cur2bytes) == 3) {	/* cmpa */
		strcat(mneu,"cmpa._  ");
		mneu[5] = BIT8(cur2bytes) ? 'l' : 'w';
		sprintf(mneu,"%s%s,%s",mneu,addregs[BITS11_9(curinstr)],
		    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
		    BIT8(cur2bytes) ? LONG : WORD,NOTSIGNED));
	}
	else if (BIT8(cur2bytes) && (BITS5_3(cur2bytes) == 1)) { /* cmpm */
		strcat(mneu,"cmpm._  ");
		mneu[5] = size[BITS7_6(cur2bytes)];
		sprintf(mneu,"%s(%s)+,(%s)+",mneu,
		    addregs[BITS11_9(cur2bytes)],
		    addregs[BITS2_0(cur2bytes)]);
	}
	else {				/* cmp or eor */
		if (BIT8(cur2bytes))
			strcat(mneu,"eor._   ");
			else
			strcat(mneu,"cmp._   ");
		mneu[4] = size[BITS7_6(cur2bytes)];
		sprintf(mneu,"%s%%d%d,%s",mneu,BITS11_9(curinstr),
		    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
		    BITS7_6(cur2bytes) +1,BIT8(cur2bytes) ?
		    UNSIGNED : SIGNED));
	}
}

void
and_mul_abcd_exg()
{
	if(BITS7_6(cur2bytes) == 3) {	/* mul */
		if (BIT8(cur2bytes))
			strcat(mneu,"muls.w  ");
			else
			strcat(mneu,"mulu.w  ");
		sprintf(mneu,"%s%s,%%d%d",mneu,eff_add(BITS5_3(cur2bytes),
		    BITS2_0(cur2bytes),WORD,
		    BIT8(cur2bytes) ? SIGNED : UNSIGNED),
		    BITS11_9(curinstr));
	}
	else if(BIT8(cur2bytes) && !BITS5_4(cur2bytes)) { /* abcd or exg */
		if (BITS8_6(cur2bytes) == 4) {	/* abcd */
			strcat(mneu,"abcd.b  ");
			if (BIT3(cur2bytes))
				sprintf(mneu,"%s-(%s),-(%s)",mneu,
				    addregs[BITS2_0(cur2bytes)],
				    addregs[BITS11_9(cur2bytes)]);
				else
				sprintf(mneu,"%s%%d%d,%%d%d",mneu,
				    BITS2_0(cur2bytes),BITS11_9(cur2bytes));
		}
		else if (BITS8_3(cur2bytes) == 050)
			sprintf(mneu,"exgd    %%d%d,%%d%d",BITS11_9(cur2bytes),
			    BITS2_0(cur2bytes));
		else if (BITS8_3(cur2bytes) == 051)
			sprintf(mneu,"exga    %s,%s",
			    addregs[BITS11_9(cur2bytes)],
			    addregs[BITS2_0(cur2bytes)]);
		else if (BITS8_3(cur2bytes) == 061)
			sprintf(mneu,"exgm    %%d%d,%s",BITS11_9(cur2bytes),
			    addregs[BITS2_0(cur2bytes)]);
		else 
			confused();
	}
	else {	/* and */
		strcat(mneu,"and._   ");
		mneu[4] = size[BITS7_6(cur2bytes)];
		if (BIT8(cur2bytes))
			sprintf(mneu,"%s%%d%d,%s",mneu,BITS11_9(curinstr),
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    NULL,NULL));
			else
			sprintf(mneu,"%s%s,%%d%d",mneu,
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    BITS7_6(cur2bytes) + 1,UNSIGNED),
			    BITS11_9(curinstr));
	}
}

void
add_addx()
{
	if (BITS7_6(cur2bytes) == 3) {	/* adda */
		strcat(mneu,"adda._  ");
		mneu[5] = BIT8(cur2bytes) ? 'l' : 'w';
		sprintf(mneu,"%s%s,%s",mneu,
		    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
		    BIT8(cur2bytes) ? LONG : WORD,UNSIGNED),
		    addregs[BITS11_9(curinstr)]);
	}
	else if (BIT8(cur2bytes) && !BITS5_4(cur2bytes)) { /* addx */
		strcat(mneu,"addx._  ");
		mneu[5] = size[BITS7_6(cur2bytes)];
		if (BIT3(cur2bytes))
			sprintf (mneu,"%s-(%s),-(%s)",mneu,
			    addregs[BITS2_0(cur2bytes)],
			    addregs[BITS11_9(cur2bytes)]);
		else 
			sprintf(mneu,"%s%%d%d,%%d%d",mneu,BITS2_0(cur2bytes),
			    BITS11_9(cur2bytes));
	}
	else {				/* add */
		strcat(mneu,"add._   ");
		mneu[4] = size[BITS7_6(cur2bytes)];
		if (BIT8(cur2bytes))
			sprintf(mneu,"%s%%d%d,%s",mneu,BITS11_9(curinstr),
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    NULL,NULL));
			else
			sprintf(mneu,"%s%s,%%d%d",mneu,
			    eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
			    BITS7_6(cur2bytes) + 1,UNSIGNED),
			    BITS11_9(curinstr));
	}
}

void
shft_rot()
{
	char	direction;		/* l -- left, r -- right	*/

	direction = BIT8(cur2bytes) ? 'l' : 'r';

	if (BITS7_6(cur2bytes) == 3)	/* Memory rotate.		*/
	{
		if (BIT11(cur2bytes) != 0)
			confused();

		switch (BITS10_9(cur2bytes))
		{
		case 0:	
			strcat(mneu,"as_.w   &1,");
			mneu[2] = direction;
			break;
		case 1: 
			strcat(mneu,"ls_.w   &1,");
			mneu[2] = direction;
			break;
		case 2: 
			strcat(mneu,"rox_.w  &1,");
			mneu[3] = direction;
			break;
		case 3: 
			strcat(mneu,"ro_.w   &1,");
			mneu[2] = direction;
			break;
		}
		strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
		    NULL,NULL));
	}
	else	/* Register rotate.		*/
	{

		switch (BITS4_3(cur2bytes))
		{
		case 0:	
			strcat(mneu,"as_._   ");
			mneu[2] = direction;
			mneu[4] = size[BITS7_6(cur2bytes)];
			break;
		case 1: 
			strcat(mneu,"ls_._   ");
			mneu[2] = direction;
			mneu[4] = size[BITS7_6(cur2bytes)];
			break;
		case 2: 
			strcat(mneu,"rox_._  ");
			mneu[3] = direction;
			mneu[5] = size[BITS7_6(cur2bytes)];
			break;
		case 3: 
			strcat(mneu,"ro_._   ");
			mneu[2] = direction;
			mneu[4] = size[BITS7_6(cur2bytes)];
			break;
		}

		if (BIT5(cur2bytes))
		{
			sprintf(conv_temp,"%%d%d,%%d%d",
			    BITS11_9(cur2bytes),BITS2_0(cur2bytes));
			strcat(mneu,conv_temp);
		}
		else
		{
			strcat(mneu,"&");
			convert(BITS11_9(cur2bytes) ? BITS11_9(cur2bytes) : 8, 
			    conv_temp, LEAD);
			sprintf(conv_temp,"%s,%%d%d", conv_temp,
			    BITS2_0(cur2bytes));
			strcat(mneu,conv_temp);
		}
	}
}	/* shft_rot()	*/



void
unassigned()
{
	printf("\tUunassigned op code around 0x%lx\n",loc);
	monrestart(MISC);
}

char *
eff_add(mode,reg,Size,sign)
int mode,reg,Size;	/* size will be NULL, BYTE, WORD, or LONG */
short sign;
{
	unsigned long fourbytes;
	static char address_fld[32];
	address_fld[0] = '\0';
	switch(mode)
	{
	case 0:			/* data register direct */
		sprintf(address_fld, "%%d%d", reg);
		break;
	case 1:			/* address register direct */
		sprintf(address_fld, "%s", addregs[reg]);
		break;
	case 2:			/* address register indirect */
		sprintf(address_fld, "(%s)", addregs[reg]);
		break;
	case 3:			/* address register indirect with post incr */
		sprintf(address_fld, "(%s)+", addregs[reg]);
		break;
	case 4:			/* address register indirect with pre decr */
		sprintf(address_fld, "-(%s)", addregs[reg]);
		break;
	case 5:			/* address register indirect with displ */
		get2bytes();
		if (BIT15(cur2bytes))
			strcat(address_fld, "-");
		convert(BIT15(cur2bytes) ? -(short) cur2bytes : cur2bytes,
		    conv_temp,LEAD);
		sprintf(address_fld,"%s%s(%s)", address_fld, conv_temp, 
		    addregs[reg]);
		break;
	case 6:			/* address register indirect with index */
		get2bytes();
		if (BITS10_8(cur2bytes))
			confused();
		if (BIT7(cur2bytes))
			strcat(address_fld, "-");
		convert(BIT7(cur2bytes) ?
		    -(short) (LOW8(cur2bytes) | 0xff00) : LOW8(cur2bytes),
		    conv_temp,LEAD);
		sprintf(address_fld,"%s%s(%s,%%%c%d.%c)", 
		    address_fld, conv_temp, addregs[reg],
		    BIT15(cur2bytes) ? 'a' : 'd' , BITS14_12(cur2bytes),
		    BIT11(cur2bytes) ? 'l' : 'w' );
		break;
	case 7:			/* absolute, pc, and immediate */
		switch(reg)		/* reg is not really a register here */
		{
		case 0:		/* absolute short */
			get2bytes();
			convert((short) cur2bytes,address_fld,LEAD);
			strcat(address_fld,".W");
			break;
		case 1:		/* absolute long */
			get2bytes();
			fourbytes = cur2bytes << 16;
			get2bytes();
			fourbytes |= cur2bytes;
			convert(fourbytes,address_fld,LEAD);
			strcat(address_fld,".L");
			break;
		case 2:		/* pc with displ */
			get2bytes();
			if (BIT15(cur2bytes))
				strcat(address_fld, "-");
			convert(BIT15(cur2bytes) ?
			    -(short) cur2bytes : cur2bytes,
			    conv_temp, LEAD);
			sprintf(address_fld, "%s%s(%%pc)",
			    address_fld, conv_temp);
			compoff((BIT15(cur2bytes) ? ((long) (short) cur2bytes) :
			    (long) cur2bytes) -2, comp_temp);
			/* the -2 above is needed because loc has been 
							   updated when getting the displacement, but 
							   for Motorola the pc is the address of the 
							   extension word */
			break;
		case 3:		/* pc with index */
			get2bytes();
			if (BITS10_8(cur2bytes))
				confused();
			if (BIT7(cur2bytes))
				strcat(address_fld, "-");
			convert(BIT7(cur2bytes) ?
			    -(short) (LOW8(cur2bytes) | 0xff00) :
			    LOW8(cur2bytes),
			    conv_temp,LEAD);
			sprintf(address_fld,"%s%s(%%pc,%%%c%d.%c)", 
			    address_fld, conv_temp, 
			    BIT15(cur2bytes) ? 'a' : 'd' ,
			    BITS14_12(cur2bytes),
			    BIT11(cur2bytes) ? 'l' : 'w' );
			compoff((BIT7(cur2bytes) ? 
			    ((long)(short) (LOW8(cur2bytes) | 0xff00)) : 
			    (long) LOW8(cur2bytes)) - 2, comp_temp);
			/* the -2 above is needed because loc has been 
							   updated when getting the index word, but 
							   for Motorola the pc is the address of
							   this word */
			sprintf(comp_temp,"%s+%%%c%d",comp_temp,
			    BIT15(cur2bytes) ? 'a' : 'd' ,
			    BITS14_12(cur2bytes));
			break;
		case 4:		/* immediate */
			switch(Size)
			{
			case NULL:
				confused();
				break;
			case BYTE:
				get2bytes();
				if (BITS15_8(cur2bytes))
					confused();
				strcat(address_fld, "&");
				if ((sign == SIGNED) && BIT7(cur2bytes))
					strcat(address_fld, "-");
				convert(((sign == SIGNED) && BIT7(cur2bytes)) ?
				    -(short) (LOW8(cur2bytes) | 0xff00) :
				    LOW8(cur2bytes),
				    conv_temp,LEAD);
				strcat(address_fld, conv_temp);
				break;
			case WORD:
				get2bytes();
				strcat(address_fld, "&");
				if ((sign == SIGNED) && BIT15(cur2bytes))
					strcat(address_fld, "-");
				convert(((sign == SIGNED) && BIT15(cur2bytes)) ?
				    -(short) cur2bytes : cur2bytes ,
				    conv_temp,LEAD);
				strcat(address_fld, conv_temp);
				break;
			case LONG:
				get2bytes();
				strcat(address_fld, "&");
				fourbytes = cur2bytes << 16;
				get2bytes();
				fourbytes |= cur2bytes;
				if ((sign == SIGNED) && HIOF32(fourbytes))
					strcat(address_fld, "-");
				convert(((sign == SIGNED) && HIOF32(fourbytes))?
				    -(long) fourbytes : fourbytes,
				    conv_temp, LEAD);
				strcat(address_fld, conv_temp);
				break;
			} /* end of size switch */
			break;
		default:
			confused();
		} /* end reg switch */
		break;
	} /* end mode switch */
	return(address_fld);
}

#endif

⌨️ 快捷键说明

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