1 /* Print IBM RS/6000 instructions for GNU software.
2 Copyright 1991 Free Software Foundation, Inc.
3 Contributed by IBM Corporation.
5 This file is part of GDB and the GNU binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #include "rs6k-opcode.h"
24 /* Print the rs6k instruction at address MEMADDR in debugged memory,
25 on STREAM. Returns length of the instruction, in bytes. */
28 print_insn (memaddr
, stream
)
32 int pop
, eop
; /* primary and extended opcodes */
34 int best
= -1; /* found best opcode index */
36 unsigned int the_insn
;
38 read_memory (memaddr
, &the_insn
, sizeof (the_insn
));
39 pop
= (unsigned)(the_insn
>> 26);
40 eop
= ((the_insn
) >> 1) & 0x3ff;
41 min
= 0, max
= NOPCODES
-1;
44 best
= (min
+ max
) / 2;
46 /* see if we are running in loops */
51 if (pop
< rs6k_ops
[best
].p_opcode
)
54 else if (pop
> rs6k_ops
[best
].p_opcode
)
58 /* opcode matched, check extended opcode. */
60 if (rs6k_ops
[best
].e_opcode
== -1) {
61 /* there is no valid extended opcode, what we've got is
66 else if (eop
< rs6k_ops
[best
].e_opcode
) {
68 while (pop
== rs6k_ops
[best
].p_opcode
) {
69 if (eop
== rs6k_ops
[best
].e_opcode
) /* found it! */
76 else if (eop
> rs6k_ops
[best
].e_opcode
) {
78 while (pop
== rs6k_ops
[best
].p_opcode
) {
79 if (eop
== rs6k_ops
[best
].e_opcode
) /* found it! */
86 else /* eop == rs6k_ops [best].e_opcode */
92 if (pop
== rs6k_ops
[best
].p_opcode
&&
93 (rs6k_ops
[best
].e_opcode
== -1 || rs6k_ops
[best
].e_opcode
== eop
))
101 print_operator (stream
, memaddr
, the_insn
, best
);
105 fprintf (stream
, "0x%08x", the_insn
);
111 /* condition code names */
112 static char *cond_code
[] = {
113 "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", "nl", "ng", "z", "nz" };
116 print_operator (stream
, memaddr
, insn_word
, insn_no
)
124 char *pp
= rs6k_ops
[insn_no
].opr_ext
;
126 int nocomma
= 0; /* true if no comma needed */
143 if ((insn_word
& 0x03e00000) == 0x01800000)
148 if ((insn_word
& 0x03e00000) == 0x00800000)
158 if (insn_word
& 0x4000)
162 case '1': /* exception #1 for bb/bc ambiguity */
163 tmp
= (insn_word
>> 21) & 0x1f; /* extract BO */
164 if (tmp
!= 0xc && tmp
!= 0x4) {
165 /* you can't use `bb' now. switch to `bc' */
168 pp
= rs6k_ops
[insn_no
].opr_ext
;
181 fprintf (stream
, "%s%s\t", rs6k_ops
[insn_no
].operator, buf
);
183 /* parse the operand now. */
184 pp
= rs6k_ops
[insn_no
].oprnd_format
;
189 fprintf (stream
, "%d", (insn_word
>> 21) & 0x1f);
194 fprintf (stream
, "r%d", (insn_word
>> 21) & 0x1f);
198 tmp
= (insn_word
>> 16) & 0x1f;
200 fprintf (stream
, "{unknown cond code: 0x%x}", insn_word
);
203 fprintf (stream
, "%s", cond_code
[tmp
]);
208 tmp
= (insn_word
& 0xfffc);
209 if (tmp
& 0x8000) /* fix sign extension */
212 if ((insn_word
& 0x2) == 0) /* if AA not set */
215 print_address (tmp
, stream
);
219 tmp
= insn_word
& 0x03fffffc;
223 if ((insn_word
& 0x2) == 0) /* if no AA bit set */
226 print_address (tmp
, stream
);
229 case LEV
: /* for svc only */
230 if (insn_word
& 0x2) { /* SA is set */
234 fprintf (stream
, "%d", (insn_word
>> 5) & 0x7f);
237 case FL1
: /* for svc only */
238 if (insn_word
& 0x2) { /* SA is set */
242 fprintf (stream
, "%d", (insn_word
>> 12) & 0xf);
245 case FL2
: /* for svc only */
247 if (insn_word
& 0x2) /* SA is set */
248 fprintf (stream
, "%d", (insn_word
>> 2) & 0x3fff);
250 fprintf (stream
, "%d", (insn_word
>> 2) & 0x7);
255 fprintf (stream
, "r%d)", (insn_word
>> 16) & 0x1f);
259 fprintf (stream
, "r%d", (insn_word
>> 16) & 0x1f);
263 fprintf (stream
, "r%d", (insn_word
>> 11) & 0x1f);
267 tmp
= insn_word
& 0xffff;
270 fprintf (stream
, "%d", tmp
);
274 fprintf (stream
, "%d", insn_word
& 0xffff);
278 fprintf (stream
, "%d", (insn_word
>> 23) & 0x7);
282 fprintf (stream
, "%d", (insn_word
>> 18) & 0x7);
286 fprintf (stream
, "%d", (insn_word
>> 21) & 0x1f);
290 fprintf (stream
, "%d", (insn_word
>> 16) & 0x1f);
294 fprintf (stream
, "%d", (insn_word
>> 11) & 0x1f);
298 fprintf (stream
, "%d", (insn_word
>> 21) & 0x1f);
302 fprintf (stream
, "%d", (insn_word
>> 16) & 0x1f);
306 fprintf (stream
, "%d", (insn_word
>> 11) & 0x1f);
310 fprintf (stream
, "0x%x", (insn_word
>> 6) & 0x1f);
314 fprintf (stream
, "0x%x", (insn_word
>> 1) & 0x1f);
318 fprintf (stream
, "%d", (insn_word
>> 16) & 0x1f);
323 tmp
= insn_word
& 0xffff;
326 fprintf (stream
, "%d(", tmp
);
330 fprintf (stream
, "0x%x", (insn_word
>> 12) & 0xff);
335 fprintf (stream
, "f%d", (insn_word
>> 21) & 0x1f);
339 fprintf (stream
, "f%d", (insn_word
>> 16) & 0x1f);
343 fprintf (stream
, "f%d", (insn_word
>> 11) & 0x1f);
347 fprintf (stream
, "f%d", (insn_word
>> 6) & 0x1f);
351 fprintf (stream
, "0x%x", (insn_word
>> 17) & 0xff);
355 fprintf (stream
, "%d", (insn_word
>> 11) & 0x1f);
359 fprintf (stream
, "%d", (insn_word
>> 12) & 0xf);
364 "{Internal error: Unknown operand format identifier %d}",
This page took 0.045492 seconds and 5 git commands to generate.