* rs6000-pinsn.c: Make dis-assembly output more like

other targets:  Don't print instruction in hex before
	the assembly;  use print_address to print out jump
	destinations.
This commit is contained in:
Per Bothner 1992-03-26 21:22:50 +00:00
parent 04f27ddc6d
commit 9efdc2feaa

View file

@ -119,13 +119,12 @@ long memaddr;
long insn_word; long insn_word;
int insn_no; int insn_no;
{ {
char buf [BUFSIZ]; char buf [20];
char *qq = buf; char *qq = buf;
char *pp = rs6k_ops[insn_no].opr_ext; char *pp = rs6k_ops[insn_no].opr_ext;
int tmp; int tmp;
int nocomma = 0; /* true if no comma needed */ int nocomma = 0; /* true if no comma needed */
*qq = '\0';
if (pp) { if (pp) {
while (*pp) { while (*pp) {
@ -177,9 +176,9 @@ int insn_no;
++pp; ++pp;
} }
} }
*qq = '\0';
/* tab between operator and operand */ fprintf (stream, "%s%s\t", rs6k_ops[insn_no].operator, buf);
*qq++ = '\t';
/* parse the operand now. */ /* parse the operand now. */
pp = rs6k_ops[insn_no].oprnd_format; pp = rs6k_ops[insn_no].oprnd_format;
@ -187,21 +186,21 @@ int insn_no;
while (1) { while (1) {
switch (*pp) { switch (*pp) {
case TO : case TO :
sprintf (qq, "%d", (insn_word >> 21) & 0x1f); fprintf (stream, "%d", (insn_word >> 21) & 0x1f);
break; break;
case RT : case RT :
case RS : case RS :
sprintf (qq, "r%d", (insn_word >> 21) & 0x1f); fprintf (stream, "r%d", (insn_word >> 21) & 0x1f);
break; break;
case LI : case LI :
tmp = (insn_word >> 16) & 0x1f; tmp = (insn_word >> 16) & 0x1f;
if (tmp > 11) { if (tmp > 11) {
fprintf (stderr, "Internal error: unknown cond code: 0x%x\n", insn_word); fprintf (stream, "{unknown cond code: 0x%x}", insn_word);
tmp = 0; tmp = 0;
} }
sprintf (qq, "%s", cond_code [tmp]); fprintf (stream, "%s", cond_code [tmp]);
break; break;
case A2 : case A2 :
@ -213,7 +212,7 @@ int insn_no;
if ((insn_word & 0x2) == 0) /* if AA not set */ if ((insn_word & 0x2) == 0) /* if AA not set */
tmp += memaddr; tmp += memaddr;
sprintf (qq, "0x%x", tmp); print_address (tmp, stream);
break; break;
case TA24 : case TA24 :
@ -224,101 +223,99 @@ int insn_no;
if ((insn_word & 0x2) == 0) /* if no AA bit set */ if ((insn_word & 0x2) == 0) /* if no AA bit set */
tmp += memaddr; tmp += memaddr;
sprintf (qq, "0x%x", tmp); print_address (tmp, stream);
break; break;
case LEV : /* for svc only */ case LEV : /* for svc only */
if (insn_word & 0x2) { /* SA is set */ if (insn_word & 0x2) { /* SA is set */
nocomma = 1; nocomma = 1;
*qq = '\0';
} }
else else
sprintf (qq, "%d", (insn_word >> 5) & 0x7f); fprintf (stream, "%d", (insn_word >> 5) & 0x7f);
break; break;
case FL1 : /* for svc only */ case FL1 : /* for svc only */
if (insn_word & 0x2) { /* SA is set */ if (insn_word & 0x2) { /* SA is set */
nocomma = 1; nocomma = 1;
*qq = '\0';
} }
else else
sprintf (qq, "%d", (insn_word >> 12) & 0xf); fprintf (stream, "%d", (insn_word >> 12) & 0xf);
break; break;
case FL2 : /* for svc only */ case FL2 : /* for svc only */
nocomma = 0; nocomma = 0;
if (insn_word & 0x2) /* SA is set */ if (insn_word & 0x2) /* SA is set */
sprintf (qq, "%d", (insn_word >> 2) & 0x3fff); fprintf (stream, "%d", (insn_word >> 2) & 0x3fff);
else else
sprintf (qq, "%d", (insn_word >> 2) & 0x7); fprintf (stream, "%d", (insn_word >> 2) & 0x7);
break; break;
case RA : case RA :
if (nocomma) { if (nocomma) {
sprintf (qq, "r%d)", (insn_word >> 16) & 0x1f); fprintf (stream, "r%d)", (insn_word >> 16) & 0x1f);
nocomma = 0; nocomma = 0;
} }
else else
sprintf (qq, "r%d", (insn_word >> 16) & 0x1f); fprintf (stream, "r%d", (insn_word >> 16) & 0x1f);
break; break;
case RB : case RB :
sprintf (qq, "r%d", (insn_word >> 11) & 0x1f); fprintf (stream, "r%d", (insn_word >> 11) & 0x1f);
break; break;
case SI : case SI :
tmp = insn_word & 0xffff; tmp = insn_word & 0xffff;
if (tmp & 0x8000) if (tmp & 0x8000)
tmp -= 0x10000; tmp -= 0x10000;
sprintf (qq, "%d", tmp); fprintf (stream, "%d", tmp);
break; break;
case UI : case UI :
sprintf (qq, "%d", insn_word & 0xffff); fprintf (stream, "%d", insn_word & 0xffff);
break; break;
case BF : case BF :
sprintf (qq, "%d", (insn_word >> 23) & 0x7); fprintf (stream, "%d", (insn_word >> 23) & 0x7);
break; break;
case BFA : case BFA :
sprintf (qq, "%d", (insn_word >> 18) & 0x7); fprintf (stream, "%d", (insn_word >> 18) & 0x7);
break; break;
case BT : case BT :
sprintf (qq, "%d", (insn_word >> 21) & 0x1f); fprintf (stream, "%d", (insn_word >> 21) & 0x1f);
break; break;
case BA : case BA :
sprintf (qq, "%d", (insn_word >> 16) & 0x1f); fprintf (stream, "%d", (insn_word >> 16) & 0x1f);
break; break;
case BB : case BB :
sprintf (qq, "%d", (insn_word >> 11) & 0x1f); fprintf (stream, "%d", (insn_word >> 11) & 0x1f);
break; break;
case BO : case BO :
sprintf (qq, "%d", (insn_word >> 21) & 0x1f); fprintf (stream, "%d", (insn_word >> 21) & 0x1f);
break; break;
case BI : case BI :
sprintf (qq, "%d", (insn_word >> 16) & 0x1f); fprintf (stream, "%d", (insn_word >> 16) & 0x1f);
break; break;
case SH : case SH :
sprintf (qq, "%d", (insn_word >> 11) & 0x1f); fprintf (stream, "%d", (insn_word >> 11) & 0x1f);
break; break;
case MB : case MB :
sprintf (qq, "0x%x", (insn_word >> 6) & 0x1f); fprintf (stream, "0x%x", (insn_word >> 6) & 0x1f);
break; break;
case ME : case ME :
sprintf (qq, "0x%x", (insn_word >> 1) & 0x1f); fprintf (stream, "0x%x", (insn_word >> 1) & 0x1f);
break; break;
case SPR : case SPR :
sprintf (qq, "%d", (insn_word >> 16) & 0x1f); fprintf (stream, "%d", (insn_word >> 16) & 0x1f);
break; break;
case DIS : case DIS :
@ -326,56 +323,52 @@ int insn_no;
tmp = insn_word & 0xffff; tmp = insn_word & 0xffff;
if (tmp & 0x8000) if (tmp & 0x8000)
tmp -= 0x10000; tmp -= 0x10000;
sprintf (qq, "%d(", tmp); fprintf (stream, "%d(", tmp);
break; break;
case FXM : case FXM :
sprintf (qq, "0x%x", (insn_word >> 12) & 0xff); fprintf (stream, "0x%x", (insn_word >> 12) & 0xff);
break; break;
case FRT : case FRT :
case FRS : case FRS :
sprintf (qq, "f%d", (insn_word >> 21) & 0x1f); fprintf (stream, "f%d", (insn_word >> 21) & 0x1f);
break; break;
case FRA : case FRA :
sprintf (qq, "f%d", (insn_word >> 16) & 0x1f); fprintf (stream, "f%d", (insn_word >> 16) & 0x1f);
break; break;
case FRB : case FRB :
sprintf (qq, "f%d", (insn_word >> 11) & 0x1f); fprintf (stream, "f%d", (insn_word >> 11) & 0x1f);
break; break;
case FRC : case FRC :
sprintf (qq, "f%d", (insn_word >> 6) & 0x1f); fprintf (stream, "f%d", (insn_word >> 6) & 0x1f);
break; break;
case FLM : case FLM :
sprintf (qq, "0x%x", (insn_word >> 17) & 0xff); fprintf (stream, "0x%x", (insn_word >> 17) & 0xff);
break; break;
case NB : case NB :
sprintf (qq, "%d", (insn_word >> 11) & 0x1f); fprintf (stream, "%d", (insn_word >> 11) & 0x1f);
break; break;
case I : case I :
sprintf (qq, "%d", (insn_word >> 12) & 0xf); fprintf (stream, "%d", (insn_word >> 12) & 0xf);
break; break;
default : default :
sprintf (qq, "Unknown operand format identifier %d????", *pp); fprintf (stream,
abort (); "{Internal error: Unknown operand format identifier %d}",
*pp);
} }
while (*qq) ++qq; /* Walk to end of string printed so far. */
++pp; ++pp;
if (*pp == '\0') if (*pp == '\0')
break; break;
else if (!nocomma) else if (!nocomma)
*qq++ = ','; fputc(',', stream);
} }
*qq = '\0';
fprintf (stream, "0x%08x\t%s%s",
insn_word, rs6k_ops[insn_no].operator, buf);
} }