dis_68k.c
来自「umon bootloader source code, support mip」· C语言 代码 · 共 1,415 行 · 第 1/3 页
C
1,415 行
eff_add(ea1,eareg,
(osz==2)?(LONG):( (osz==1)?(WORD):(BYTE) ),
NULL));
if (regtype)
strcpy(rreg,addregs[regnum]);
else
sprintf(rreg,"%%d%1d",regnum);
strcat(mneu,(movsdir)?(rreg):(curea));
strcat(mneu,",");
strcat(mneu,(movsdir)?(curea):(rreg));
}
#else
case 7:
confused();
#endif
}
}
void
move_byte()
{
if (BITS8_6(cur2bytes) == 0x1L )
confused();
else {
strcat(mneu,"mov.b ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),BYTE,
NOTSIGNED));
strcat(mneu,",");
strcat(mneu,eff_add(BITS8_6(curinstr),BITS11_9(curinstr),NULL,
NULL));
}
} /* move_byte() */
void
move_long()
{
if (BITS8_6(cur2bytes) == 0x1L )
move_address();
else {
strcat(mneu,"mov.l ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),LONG,
NOTSIGNED));
strcat(mneu,",");
strcat(mneu,eff_add(BITS8_6(curinstr),BITS11_9(curinstr),NULL,
NULL));
}
} /* move_long() */
void
move_word()
{
if (BITS8_6(cur2bytes) == 0x1L )
move_address();
else {
strcat(mneu,"mov.w ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),WORD,
NOTSIGNED));
strcat(mneu,",");
strcat(mneu,eff_add(BITS8_6(curinstr),BITS11_9(curinstr),NULL,
NULL));
}
} /* move_word() */
void
miscell()
{
if (BIT8(cur2bytes))
{
if (!BIT7(cur2bytes))
confused();
if (BIT6(cur2bytes))
sprintf(mneu,"lea.l %s,%s",eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),LONG,UNSIGNED),
addregs[BITS11_9(curinstr)]);
else
sprintf(mneu,"chk.w %s,%%d%d",
eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
WORD,UNSIGNED),BITS11_9(curinstr));
return;
}
switch (BITS11_9(cur2bytes))
{
case 0:
if (BITS7_6(cur2bytes) == 3) {
strcat(mneu,"mov.w %sr,");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
}
else {
strcat(mneu,"negx._ ");
mneu[5] = size[BITS7_6(cur2bytes)];
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
}
return;
case 1:
if (BITS7_6(cur2bytes) == 3) {
#ifdef M68010
strcat(mneu,"mov.w %cc,");
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
WORD,NULL));
return;
#else
confused();
#endif
}
strcat(mneu,"clr._ ");
mneu[4] = size[BITS7_6(cur2bytes)];
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
NULL,NULL));
return;
case 2:
if (BITS7_6(cur2bytes) == 3)
{
strcat(mneu,"mov.w ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),WORD,UNSIGNED));
strcat(mneu,",%cc");
return;
}
strcat(mneu,"neg._ ");
mneu[4] = size[BITS7_6(cur2bytes)];
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
NULL,NULL));
return;
case 3:
if (BITS7_6(cur2bytes) == 3)
{
strcat(mneu,"mov.w ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),WORD,UNSIGNED));
strcat(mneu,",%sr");
return;
}
strcat(mneu,"not._ ");
mneu[4] = size[BITS7_6(cur2bytes)];
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
NULL,NULL));
return;
case 5:
if (BITS7_6(cur2bytes) == 3)
{
if (BITS5_0(cur2bytes) == 074) {
unsigned short i;
if (BITS15_7(oldinstr) == 0235){
get2bytes();
curinstr = cur2bytes;
convert(cur2bytes,conv_temp,LEAD);
sprintf(mneu,"swbeg &%s",conv_temp);
for(i=1;i<=curinstr;i++) {
print_dis();
printf("\t");
/* no need to call line_ nums - just need tab */
mneu[0] = '\0';
prt_offset();
strcat(mneu,eff_add(7,4,WORD,
NOTSIGNED));
}
return;
}
else {
sprintf(mneu,"illegal ");
return;
}
}
strcat(mneu,"tas.b ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
return;
}
strcat(mneu,"tst._ ");
mneu[4] = size[BITS7_6(cur2bytes)];
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
NULL,NULL));
return;
case 4:
switch(BITS7_6(cur2bytes)) {
case 0:
strcat(mneu,"nbcd.b ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
return;
case 1:
#ifdef M68010
if (BITS5_3(cur2bytes) == 1) {
char atemp[4];
strcat(mneu,"bkpt &");
sprintf(atemp,"%d", BITS2_0(cur2bytes));
strcat(mneu,atemp);
return;
}
else
#endif
if (BITS5_3(cur2bytes)) {
strcat(mneu,"pea.l ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
return;
}
else {
sprintf(mneu,"swap.w %%d%d",
BITS2_0(cur2bytes));
return;
}
case 2:
if (!BITS5_3(cur2bytes)) {
sprintf(mneu,"ext.w %%d%d",
BITS2_0(cur2bytes));
return;
}
/* movem falls thru here */
case 3:
if (!BITS5_3(cur2bytes)) {
sprintf(mneu,"ext.l %%d%d",
BITS2_0(cur2bytes));
return;
}
/* movem falls thru here */
} /* end switch BITS7_6 */
case 6:
{
unsigned short mask; /* gets movm.[wl] mask */
char add_temp[25];
add_temp[0] = '\0';
if (!BIT7(cur2bytes))
confused();
get2bytes(); /* read mask and save */
mask = cur2bytes;
strcpy(mneu,"movm._ ");
mneu[5] = BIT6(curinstr) ? 'l' : 'w';
strcat(add_temp,eff_add(BITS5_3(curinstr),BITS2_0(curinstr),
NULL,NULL));
if(BIT10(curinstr))
sprintf(mneu,"%s%s,",mneu,add_temp);
strcat(mneu,"&");
convert(mask, conv_temp,LEAD);
strcat(mneu,conv_temp);
if (!BIT10(curinstr))
sprintf(mneu,"%s,%s",mneu,add_temp);
return;
}
case 7:
switch (BITS7_6(cur2bytes))
{
case 0:
confused();
case 1:
switch (BITS5_4(cur2bytes))
{
case 0:
strcat(mneu,"trap &");
convert(BITS3_0(cur2bytes),conv_temp,LEAD);
strcat(mneu,conv_temp);
return;
case 1:
if (BIT3(cur2bytes))
sprintf(mneu,"unlk %s",
addregs[BITS2_0(cur2bytes)]);
else
{
sprintf(mneu,"link %s,&",
addregs[BITS2_0(cur2bytes)]);
get2bytes();
if (BIT15(cur2bytes))
strcat(mneu,"-");
convert(BIT15(cur2bytes) ?
-(short)cur2bytes : cur2bytes,
conv_temp,LEAD);
strcat(mneu,conv_temp);
}
return;
case 2:
if (BIT3(cur2bytes))
sprintf(mneu,"mov.l %%usp,%s",
addregs[BITS2_0(cur2bytes)]);
else
sprintf(mneu,"mov.l %s,%%usp",
addregs[BITS2_0(cur2bytes)]);
return;
case 3:
{
static char *misc_ops[8] =
{
"reset",
"nop",
"stop &",
"rte",
"",
"rts",
"trapv",
"rtr"
};
#ifdef M68010
if (BIT3(cur2bytes) &&
(BITS2_0(cur2bytes) == 2 ||
BITS2_0(cur2bytes) == 3))
{
short movcdir, regtype, regnum;
char rreg[6], creg[6];
movcdir = cur2bytes & 0x01;
get2bytes();
regtype = BIT15(cur2bytes);
regnum = BITS14_12(cur2bytes);
if (regtype)
strcpy(rreg,addregs[regnum]);
else
sprintf(rreg,"%%d%1d",regnum);
regnum = cur2bytes & 0x0fff;
if (regnum == 0) strcpy(creg,"%sfc");
else
if (regnum == 1) strcpy(creg,"%dfc");
else
if (regnum == 0x0800) strcpy(creg,"%usp");
else
/* code folded from here */
if (regnum == 0x0801) strcpy(creg,"%vbr");
else
confused();
/* unfolding */
strcat(mneu,"movc.l ");
if (movcdir) {
strcat(mneu,rreg);
strcat(mneu,",");
strcat(mneu,creg);
}
else {
strcat(mneu,creg);
strcat(mneu,",");
strcat(mneu,rreg);
}
return;
}
else
if (BIT3(cur2bytes) == 0 &&
BITS2_0(cur2bytes) == 4) {
char disptemp[16];
strcat(mneu,"rtd &");
get2bytes();
sprintf(disptemp,"%d",cur2bytes);
strcat(mneu,disptemp);
return;
}
else
#endif
if (BIT3(cur2bytes)||(BITS2_0(cur2bytes) ==4))
confused();
strcat(mneu,misc_ops[BITS2_0(cur2bytes)]);
if (BITS2_0(cur2bytes) == 2) /* stop */
{
get2bytes();
convert(cur2bytes,conv_temp,LEAD);
strcat(mneu,conv_temp);
}
return;
}
} /* switch (BITS5_4(cur2bytes)) */
case 2:
strcat(mneu,"jsr ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
return;
case 3:
strcat(mneu,"jmp ");
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
return;
} /* switch (BITS7_6(cur2bytes)) */
} /* switch (BITS11_9(cur2bytes)) */
} /* miscell() */
void
addq_subq_scc_dbcc()
{
if (BITS7_6(cur2bytes) == 3) {
if (BITS5_3(cur2bytes) == 1) {
strcat(mneu,"db");
strcat(mneu,cond_codes[BITS11_8(cur2bytes)]);
/* dbCC is one character longer than other CCs, */
/* so null out the ninth byte to keep aligned. */
mneu[8] = '\0';
sprintf(conv_temp,"%%d%d,",BITS2_0(cur2bytes));
strcat(mneu,conv_temp);
get2bytes();
if (BIT15(cur2bytes))
strcat(mneu,"-");
convert(BIT15(cur2bytes) ? -(short) cur2bytes :
cur2bytes,conv_temp,LEAD);
strcat(mneu,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 */
}
else {
strcat(mneu,"s");
strcat(mneu,cond_codes[BITS11_8(cur2bytes)]);
if (BITS11_8(cur2bytes) < 2)
{
/* cc is only one character */
mneu[2] = '.';
mneu[3] = 'b';
}
else
{
/* cc is two characters */
mneu[3] = '.';
mneu[4] = 'b';
}
strcat(mneu,eff_add(BITS5_3(cur2bytes),
BITS2_0(cur2bytes),NULL,NULL));
}
}
else
{
strcpy(mneu,BIT8(cur2bytes) ? "subq._ &" : "addq._ &");
mneu[5] = size[BITS7_6(cur2bytes)];
convert(BITS11_9(cur2bytes) ? BITS11_9(cur2bytes) : 8,
conv_temp,LEAD);
strcat(mneu,conv_temp);
strcat(mneu,",");
strcat(mneu,eff_add(BITS5_3(cur2bytes),BITS2_0(cur2bytes),
NULL,NULL));
}
} /* addq_subq_scc_dbcc() */
void
bcc_bsr_bra()
{
strcpy(mneu,"b");
if (BITS11_8(cur2bytes) == 1)
strcat(mneu,"sr ");
else if (BITS11_8(cur2bytes) == 0)
strcat(mneu,"ra ");
else
strcat(mneu,cond_codes[BITS11_8(cur2bytes)]);
if (LOW8(cur2bytes))
{
mneu[3] = '.';
mneu[4] = 'b';
convert(BIT7(cur2bytes) ?
-((short) ( LOW8(cur2bytes) | 0xff00)) :
LOW8(cur2bytes),conv_temp,LEAD);
compoff(BIT7(cur2bytes) ?
((long)(short) (LOW8(cur2bytes) | 0xff00)) :
(long) LOW8(cur2bytes), comp_temp);
if (BIT7(cur2bytes))
strcat(mneu,"-");
}
else
{
get2bytes();
convert(BIT15(cur2bytes) ? -((short) cur2bytes) :
cur2bytes,conv_temp,LEAD);
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 */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?