1 /* Print rs6000 instructions for objdump.
2 This file is part of the binutils.
8 #include "rs6k-opcode.h"
11 /* Print the rs6k instruction at address MEMADDR in debugged memory,
12 on STREAM. Returns length of the instruction, in bytes. */
15 print_insn (memaddr
, stream
)
19 int pop
, eop
; /* primary and extended opcodes */
21 int best
= -1; /* found best opcode index */
23 unsigned int the_insn
;
25 read_memory (memaddr
, &the_insn
, sizeof (the_insn
));
26 pop
= (unsigned)(the_insn
>> 26);
27 eop
= ((the_insn
) >> 1) & 0x3ff;
28 min
= 0, max
= NOPCODES
-1;
31 best
= (min
+ max
) / 2;
33 /* see if we are running in loops */
38 if (pop
< rs6k_ops
[best
].p_opcode
)
41 else if (pop
> rs6k_ops
[best
].p_opcode
)
45 /* opcode matched, check extended opcode. */
47 if (rs6k_ops
[best
].e_opcode
== -1) {
48 /* there is no valid extended opcode, what we've got is
53 else if (eop
< rs6k_ops
[best
].e_opcode
) {
55 while (pop
== rs6k_ops
[best
].p_opcode
) {
56 if (eop
== rs6k_ops
[best
].e_opcode
) /* found it! */
63 else if (eop
> rs6k_ops
[best
].e_opcode
) {
65 while (pop
== rs6k_ops
[best
].p_opcode
) {
66 if (eop
== rs6k_ops
[best
].e_opcode
) /* found it! */
73 else /* eop == rs6k_ops [best].e_opcode */
79 if (pop
== rs6k_ops
[best
].p_opcode
&&
80 (rs6k_ops
[best
].e_opcode
== -1 || rs6k_ops
[best
].e_opcode
== eop
))
88 print_operator (stream
, memaddr
, the_insn
, best
);
92 fprintf (stream
, "0x%08x", the_insn
);
98 /* condition code names */
99 static char *cond_code
[] = {
100 "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", "nl", "ng", "z", "nz" };
103 print_operator (stream
, memaddr
, insn_word
, insn_no
)
111 char *pp
= rs6k_ops
[insn_no
].opr_ext
;
113 int nocomma
= 0; /* true if no comma needed */
131 if ((insn_word
& 0x03e00000) == 0x01800000)
136 if ((insn_word
& 0x03e00000) == 0x00800000)
146 if (insn_word
& 0x4000)
150 case '1': /* exception #1 for bb/bc ambiguity */
151 tmp
= (insn_word
>> 21) & 0x1f; /* extract BO */
152 if (tmp
!= 0xc && tmp
!= 0x4) {
153 /* you can't use `bb' now. switch to `bc' */
156 pp
= rs6k_ops
[insn_no
].opr_ext
;
168 /* tab between orerator and operand */
171 /* parse the operand now. */
172 pp
= rs6k_ops
[insn_no
].oprnd_format
;
177 sprintf (qq
, "%d", (insn_word
>> 21) & 0x1f);
182 sprintf (qq
, "r%d", (insn_word
>> 21) & 0x1f);
186 tmp
= (insn_word
>> 16) & 0x1f;
188 fprintf (stderr
, "Internal error: unknown cond code: 0x%x\n", insn_word
);
191 sprintf (qq
, "%s", cond_code
[tmp
]);
196 tmp
= (insn_word
>> 2) & 0x3fff;
199 sprintf (qq
, "0x%x", tmp
* 4 + memaddr
);
204 tmp
= (insn_word
& 0xfffc);
205 if (tmp
& 0x8000) /* fix sign extension */
208 if ((insn_word
& 0x2) == 0) /* if AA not set */
211 sprintf (qq
, "0x%x", tmp
);
215 tmp
= insn_word
& 0x03fffffc;
219 if ((insn_word
& 0x2) == 0) /* if no AA bit set */
222 sprintf (qq
, "0x%x", tmp
);
225 case LEV
: /* for svc only */
226 if (insn_word
& 0x2) { /* SA is set */
231 sprintf (qq
, "%d", (insn_word
>> 5) & 0x7f);
234 case FL1
: /* for svc only */
235 if (insn_word
& 0x2) { /* SA is set */
240 sprintf (qq
, "%d", (insn_word
>> 12) & 0xf);
243 case FL2
: /* for svc only */
245 if (insn_word
& 0x2) /* SA is set */
246 sprintf (qq
, "%d", (insn_word
>> 2) & 0x3fff);
248 sprintf (qq
, "%d", (insn_word
>> 2) & 0x7);
253 sprintf (qq
, "r%d)", (insn_word
>> 16) & 0x1f);
257 sprintf (qq
, "r%d", (insn_word
>> 16) & 0x1f);
261 sprintf (qq
, "r%d", (insn_word
>> 11) & 0x1f);
265 tmp
= insn_word
& 0xffff;
268 sprintf (qq
, "%d", tmp
);
272 sprintf (qq
, "%d", insn_word
& 0xffff);
276 sprintf (qq
, "%d", (insn_word
>> 23) & 0x7);
280 sprintf (qq
, "%d", (insn_word
>> 18) & 0x7);
284 sprintf (qq
, "%d", (insn_word
>> 21) & 0x1f);
288 sprintf (qq
, "%d", (insn_word
>> 16) & 0x1f);
292 sprintf (qq
, "%d", (insn_word
>> 11) & 0x1f);
296 sprintf (qq
, "%d", (insn_word
>> 21) & 0x1f);
300 sprintf (qq
, "%d", (insn_word
>> 16) & 0x1f);
304 sprintf (qq
, "%d", (insn_word
>> 11) & 0x1f);
308 sprintf (qq
, "0x%x", (insn_word
>> 6) & 0x1f);
312 sprintf (qq
, "0x%x", (insn_word
>> 1) & 0x1f);
316 sprintf (qq
, "%d", (insn_word
>> 16) & 0x1f);
321 tmp
= insn_word
& 0xffff;
324 sprintf (qq
, "%d(", tmp
);
328 sprintf (qq
, "0x%x", (insn_word
>> 12) & 0xff);
333 sprintf (qq
, "f%d", (insn_word
>> 21) & 0x1f);
337 sprintf (qq
, "f%d", (insn_word
>> 16) & 0x1f);
341 sprintf (qq
, "f%d", (insn_word
>> 11) & 0x1f);
345 sprintf (qq
, "f%d", (insn_word
>> 6) & 0x1f);
349 sprintf (qq
, "0x%x", (insn_word
>> 17) & 0xff);
353 sprintf (qq
, "%d", (insn_word
>> 11) & 0x1f);
357 sprintf (qq
, "%d", (insn_word
>> 12) & 0xf);
361 sprintf (qq
, "Unknown operand format identifier????");
374 fprintf (stream
, "0x%08x\t%s%s",
375 insn_word
, rs6k_ops
[insn_no
].operator, buf
);
This page took 0.05324 seconds and 4 git commands to generate.