1 /* Print mips instructions for GDB, the GNU debugger, or for objdump.
2 Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
5 Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp).
7 This file is part of GDB, GAS, and the GNU binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "opcode/mips.h"
28 /* FIXME: These are needed to figure out if the code is mips16 or
29 not. The low bit of the address is often a good indicator. No
30 symbol table is available when this code runs out in an embedded
31 system as when it is used for disassembler support in a monitor. */
33 #if !defined(EMBEDDED_ENV)
34 #define SYMTAB_AVAILABLE 1
39 /* Mips instructions are at maximum this many bytes long. */
42 static int _print_insn_mips
43 PARAMS ((bfd_vma
, struct disassemble_info
*, enum bfd_endian
));
44 static int print_insn_mips
45 PARAMS ((bfd_vma
, unsigned long int, struct disassemble_info
*));
46 static void print_insn_arg
47 PARAMS ((const char *, unsigned long, bfd_vma
, struct disassemble_info
*));
48 static int print_insn_mips16
49 PARAMS ((bfd_vma
, struct disassemble_info
*));
50 static void print_mips16_insn_arg
51 PARAMS ((int, const struct mips_opcode
*, int, boolean
, int, bfd_vma
,
52 struct disassemble_info
*));
54 /* FIXME: These should be shared with gdb somehow. */
56 /* The mips16 register names. */
57 static const char * const mips16_reg_names
[] = {
58 "s0", "s1", "v0", "v1", "a0", "a1", "a2", "a3"
61 static const char * const mips32_reg_names
[] = {
62 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
63 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
64 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
65 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
66 "sr", "lo", "hi", "bad", "cause", "pc",
67 "fv0", "$f1", "fv1", "$f3", "ft0", "$f5", "ft1", "$f7",
68 "ft2", "$f9", "ft3", "$f11", "fa0", "$f13", "fa1", "$f15",
69 "ft4", "f17", "ft5", "f19", "fs0", "f21", "fs1", "f23",
70 "fs2", "$f25", "fs3", "$f27", "fs4", "$f29", "fs5", "$f31",
71 "fsr", "fir", "fp", "inx", "rand", "tlblo", "ctxt", "tlbhi",
75 static const char * const mips64_reg_names
[] = {
76 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
77 "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3",
78 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
79 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
80 "sr", "lo", "hi", "bad", "cause", "pc",
81 "fv0", "$f1", "fv1", "$f3", "ft0", "ft1", "ft2", "ft3",
82 "ft4", "ft5", "ft6", "ft7", "fa0", "fa1", "fa2", "fa3",
83 "fa4", "fa5", "fa6", "fa7", "ft8", "ft9", "ft10", "ft11",
84 "fs0", "fs1", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7",
85 "fsr", "fir", "fp", "inx", "rand", "tlblo", "ctxt", "tlbhi",
89 /* Scalar register names. _print_insn_mips() decides which register name
91 static const char * const *reg_names
= NULL
;
93 /* Print insn arguments for 32/64-bit code. */
96 print_insn_arg (d
, l
, pc
, info
)
98 register unsigned long int l
;
100 struct disassemble_info
*info
;
109 (*info
->fprintf_func
) (info
->stream
, "%c", *d
);
116 (*info
->fprintf_func
) (info
->stream
, "%s",
117 reg_names
[(l
>> OP_SH_RS
) & OP_MASK_RS
]);
122 (*info
->fprintf_func
) (info
->stream
, "%s",
123 reg_names
[(l
>> OP_SH_RT
) & OP_MASK_RT
]);
128 (*info
->fprintf_func
) (info
->stream
, "0x%x",
129 (l
>> OP_SH_IMMEDIATE
) & OP_MASK_IMMEDIATE
);
132 case 'j': /* Same as i, but sign-extended. */
134 delta
= (l
>> OP_SH_DELTA
) & OP_MASK_DELTA
;
137 (*info
->fprintf_func
) (info
->stream
, "%d",
142 (*info
->fprintf_func
) (info
->stream
, "0x%x",
143 (unsigned int) ((l
>> OP_SH_PREFX
)
148 (*info
->fprintf_func
) (info
->stream
, "0x%x",
149 (unsigned int) ((l
>> OP_SH_CACHE
)
154 (*info
->print_address_func
)
155 ((((pc
+ 4) & ~(bfd_vma
) 0x0fffffff)
156 | (((l
>> OP_SH_TARGET
) & OP_MASK_TARGET
) << 2)),
161 /* Sign extend the displacement. */
162 delta
= (l
>> OP_SH_DELTA
) & OP_MASK_DELTA
;
165 (*info
->print_address_func
)
166 ((delta
<< 2) + pc
+ INSNLEN
,
171 (*info
->fprintf_func
) (info
->stream
, "%s",
172 reg_names
[(l
>> OP_SH_RD
) & OP_MASK_RD
]);
177 /* First check for both rd and rt being equal. */
178 unsigned int reg
= (l
>> OP_SH_RD
) & OP_MASK_RD
;
179 if (reg
== ((l
>> OP_SH_RT
) & OP_MASK_RT
))
180 (*info
->fprintf_func
) (info
->stream
, "%s",
184 /* If one is zero use the other. */
186 (*info
->fprintf_func
) (info
->stream
, "%s",
187 reg_names
[(l
>> OP_SH_RT
) & OP_MASK_RT
]);
188 else if (((l
>> OP_SH_RT
) & OP_MASK_RT
) == 0)
189 (*info
->fprintf_func
) (info
->stream
, "%s",
191 else /* Bogus, result depends on processor. */
192 (*info
->fprintf_func
) (info
->stream
, "%s or %s",
194 reg_names
[(l
>> OP_SH_RT
) & OP_MASK_RT
]);
200 (*info
->fprintf_func
) (info
->stream
, "%s", reg_names
[0]);
204 (*info
->fprintf_func
) (info
->stream
, "0x%x",
205 (l
>> OP_SH_SHAMT
) & OP_MASK_SHAMT
);
209 (*info
->fprintf_func
) (info
->stream
, "0x%x",
210 (l
>> OP_SH_CODE
) & OP_MASK_CODE
);
214 (*info
->fprintf_func
) (info
->stream
, "0x%x",
215 (l
>> OP_SH_CODE2
) & OP_MASK_CODE2
);
219 (*info
->fprintf_func
) (info
->stream
, "0x%x",
220 (l
>> OP_SH_COPZ
) & OP_MASK_COPZ
);
224 (*info
->fprintf_func
) (info
->stream
, "0x%x",
225 (l
>> OP_SH_CODE20
) & OP_MASK_CODE20
);
229 (*info
->fprintf_func
) (info
->stream
, "0x%x",
230 (l
>> OP_SH_CODE19
) & OP_MASK_CODE19
);
235 (*info
->fprintf_func
) (info
->stream
, "$f%d",
236 (l
>> OP_SH_FS
) & OP_MASK_FS
);
241 (*info
->fprintf_func
) (info
->stream
, "$f%d",
242 (l
>> OP_SH_FT
) & OP_MASK_FT
);
246 (*info
->fprintf_func
) (info
->stream
, "$f%d",
247 (l
>> OP_SH_FD
) & OP_MASK_FD
);
251 (*info
->fprintf_func
) (info
->stream
, "$f%d",
252 (l
>> OP_SH_FR
) & OP_MASK_FR
);
256 (*info
->fprintf_func
) (info
->stream
, "$%d",
257 (l
>> OP_SH_RT
) & OP_MASK_RT
);
261 (*info
->fprintf_func
) (info
->stream
, "$%d",
262 (l
>> OP_SH_RD
) & OP_MASK_RD
);
266 (*info
->fprintf_func
) (info
->stream
, "$fcc%d",
267 (l
>> OP_SH_BCC
) & OP_MASK_BCC
);
271 (*info
->fprintf_func
) (info
->stream
, "$fcc%d",
272 (l
>> OP_SH_CCC
) & OP_MASK_CCC
);
276 (*info
->fprintf_func
) (info
->stream
, "%d",
277 (l
>> OP_SH_PERFREG
) & OP_MASK_PERFREG
);
281 (*info
->fprintf_func
) (info
->stream
, "%d",
282 (l
>> OP_SH_SEL
) & OP_MASK_SEL
);
286 /* xgettext:c-format */
287 (*info
->fprintf_func
) (info
->stream
,
288 _("# internal error, undefined modifier(%c)"),
294 /* Figure out the MIPS ISA and CPU based on the machine number. */
297 mips_isa_type (mach
, isa
, cputype
)
304 case bfd_mach_mips3000
:
305 *cputype
= CPU_R3000
;
308 case bfd_mach_mips3900
:
309 *cputype
= CPU_R3900
;
312 case bfd_mach_mips4000
:
313 *cputype
= CPU_R4000
;
316 case bfd_mach_mips4010
:
317 *cputype
= CPU_R4010
;
320 case bfd_mach_mips4100
:
321 *cputype
= CPU_VR4100
;
324 case bfd_mach_mips4111
:
325 *cputype
= CPU_R4111
;
328 case bfd_mach_mips4300
:
329 *cputype
= CPU_R4300
;
332 case bfd_mach_mips4400
:
333 *cputype
= CPU_R4400
;
336 case bfd_mach_mips4600
:
337 *cputype
= CPU_R4600
;
340 case bfd_mach_mips4650
:
341 *cputype
= CPU_R4650
;
344 case bfd_mach_mips5000
:
345 *cputype
= CPU_R5000
;
348 case bfd_mach_mips6000
:
349 *cputype
= CPU_R6000
;
352 case bfd_mach_mips8000
:
353 *cputype
= CPU_R8000
;
356 case bfd_mach_mips10000
:
357 *cputype
= CPU_R10000
;
360 case bfd_mach_mips12000
:
361 *cputype
= CPU_R12000
;
364 case bfd_mach_mips16
:
365 *cputype
= CPU_MIPS16
;
368 case bfd_mach_mips32
:
369 *cputype
= CPU_MIPS32
;
372 case bfd_mach_mips32_4k
:
373 *cputype
= CPU_MIPS32_4K
;
377 *cputype
= CPU_MIPS5
;
380 case bfd_mach_mips64
:
381 *cputype
= CPU_MIPS64
;
384 case bfd_mach_mips_sb1
:
389 *cputype
= CPU_R3000
;
395 /* Check if the object uses NewABI conventions. */
399 Elf_Internal_Ehdr
*header
;
402 & (E_MIPS_ABI_EABI32
| E_MIPS_ABI_EABI64
| EF_MIPS_ABI2
)) != 0
403 || (header
->e_ident
[EI_CLASS
] == ELFCLASS64
404 && (header
->e_flags
& E_MIPS_ABI_O64
) == 0))
410 /* Print the mips instruction at address MEMADDR in debugged memory,
411 on using INFO. Returns length of the instruction, in bytes, which is
412 always INSNLEN. BIGENDIAN must be 1 if this is big-endian code, 0 if
413 this is little-endian code. */
416 print_insn_mips (memaddr
, word
, info
)
418 unsigned long int word
;
419 struct disassemble_info
*info
;
421 register const struct mips_opcode
*op
;
422 int target_processor
, mips_isa
;
423 static boolean init
= 0;
424 static const struct mips_opcode
*mips_hash
[OP_MASK_OP
+ 1];
426 /* Build a hash table to shorten the search time. */
431 for (i
= 0; i
<= OP_MASK_OP
; i
++)
433 for (op
= mips_opcodes
; op
< &mips_opcodes
[NUMOPCODES
]; op
++)
435 if (op
->pinfo
== INSN_MACRO
)
437 if (i
== ((op
->match
>> OP_SH_OP
) & OP_MASK_OP
))
448 #if ! SYMTAB_AVAILABLE
449 /* This is running out on a target machine, not in a host tool.
450 FIXME: Where does mips_target_info come from? */
451 target_processor
= mips_target_info
.processor
;
452 mips_isa
= mips_target_info
.isa
;
454 mips_isa_type (info
->mach
, &mips_isa
, &target_processor
);
457 info
->bytes_per_chunk
= INSNLEN
;
458 info
->display_endian
= info
->endian
;
460 op
= mips_hash
[(word
>> OP_SH_OP
) & OP_MASK_OP
];
463 for (; op
< &mips_opcodes
[NUMOPCODES
]; op
++)
465 if (op
->pinfo
!= INSN_MACRO
&& (word
& op
->mask
) == op
->match
)
467 register const char *d
;
469 if (! OPCODE_IS_MEMBER (op
, mips_isa
, target_processor
))
472 (*info
->fprintf_func
) (info
->stream
, "%s", op
->name
);
475 if (d
!= NULL
&& *d
!= '\0')
477 (*info
->fprintf_func
) (info
->stream
, "\t");
478 for (; *d
!= '\0'; d
++)
479 print_insn_arg (d
, word
, memaddr
, info
);
487 /* Handle undefined instructions. */
488 (*info
->fprintf_func
) (info
->stream
, "0x%x", word
);
492 /* In an environment where we do not know the symbol type of the
493 instruction we are forced to assume that the low order bit of the
494 instructions' address may mark it as a mips16 instruction. If we
495 are single stepping, or the pc is within the disassembled function,
496 this works. Otherwise, we need a clue. Sometimes. */
499 _print_insn_mips (memaddr
, info
, endianness
)
501 struct disassemble_info
*info
;
502 enum bfd_endian endianness
;
504 bfd_byte buffer
[INSNLEN
];
508 /* FIXME: If odd address, this is CLEARLY a mips 16 instruction. */
509 /* Only a few tools will work this way. */
511 return print_insn_mips16 (memaddr
, info
);
516 || (info
->flavour
== bfd_target_elf_flavour
517 && info
->symbols
!= NULL
518 && ((*(elf_symbol_type
**) info
->symbols
)->internal_elf_sym
.st_other
520 return print_insn_mips16 (memaddr
, info
);
523 /* Use mips64_reg_names for new ABI. */
524 reg_names
= mips32_reg_names
;
526 if (info
->flavour
== bfd_target_elf_flavour
&& info
->symbols
!= NULL
)
528 Elf_Internal_Ehdr
*header
;
530 header
= elf_elfheader (bfd_asymbol_bfd (*(info
->symbols
)));
531 if (is_newabi (header
))
532 reg_names
= mips64_reg_names
;
535 status
= (*info
->read_memory_func
) (memaddr
, buffer
, INSNLEN
, info
);
540 if (endianness
== BFD_ENDIAN_BIG
)
541 insn
= (unsigned long) bfd_getb32 (buffer
);
543 insn
= (unsigned long) bfd_getl32 (buffer
);
545 return print_insn_mips (memaddr
, insn
, info
);
549 (*info
->memory_error_func
) (status
, memaddr
, info
);
555 print_insn_big_mips (memaddr
, info
)
557 struct disassemble_info
*info
;
559 return _print_insn_mips (memaddr
, info
, BFD_ENDIAN_BIG
);
563 print_insn_little_mips (memaddr
, info
)
565 struct disassemble_info
*info
;
567 return _print_insn_mips (memaddr
, info
, BFD_ENDIAN_LITTLE
);
570 /* Disassemble mips16 instructions. */
573 print_insn_mips16 (memaddr
, info
)
575 struct disassemble_info
*info
;
583 const struct mips_opcode
*op
, *opend
;
585 info
->bytes_per_chunk
= 2;
586 info
->display_endian
= info
->endian
;
587 info
->insn_info_valid
= 1;
588 info
->branch_delay_insns
= 0;
590 info
->insn_type
= dis_nonbranch
;
594 status
= (*info
->read_memory_func
) (memaddr
, buffer
, 2, info
);
597 (*info
->memory_error_func
) (status
, memaddr
, info
);
603 if (info
->endian
== BFD_ENDIAN_BIG
)
604 insn
= bfd_getb16 (buffer
);
606 insn
= bfd_getl16 (buffer
);
608 /* Handle the extend opcode specially. */
610 if ((insn
& 0xf800) == 0xf000)
613 extend
= insn
& 0x7ff;
617 status
= (*info
->read_memory_func
) (memaddr
, buffer
, 2, info
);
620 (*info
->fprintf_func
) (info
->stream
, "extend 0x%x",
621 (unsigned int) extend
);
622 (*info
->memory_error_func
) (status
, memaddr
, info
);
626 if (info
->endian
== BFD_ENDIAN_BIG
)
627 insn
= bfd_getb16 (buffer
);
629 insn
= bfd_getl16 (buffer
);
631 /* Check for an extend opcode followed by an extend opcode. */
632 if ((insn
& 0xf800) == 0xf000)
634 (*info
->fprintf_func
) (info
->stream
, "extend 0x%x",
635 (unsigned int) extend
);
636 info
->insn_type
= dis_noninsn
;
643 /* FIXME: Should probably use a hash table on the major opcode here. */
645 opend
= mips16_opcodes
+ bfd_mips16_num_opcodes
;
646 for (op
= mips16_opcodes
; op
< opend
; op
++)
648 if (op
->pinfo
!= INSN_MACRO
&& (insn
& op
->mask
) == op
->match
)
652 if (strchr (op
->args
, 'a') != NULL
)
656 (*info
->fprintf_func
) (info
->stream
, "extend 0x%x",
657 (unsigned int) extend
);
658 info
->insn_type
= dis_noninsn
;
666 status
= (*info
->read_memory_func
) (memaddr
, buffer
, 2,
671 if (info
->endian
== BFD_ENDIAN_BIG
)
672 extend
= bfd_getb16 (buffer
);
674 extend
= bfd_getl16 (buffer
);
679 (*info
->fprintf_func
) (info
->stream
, "%s", op
->name
);
680 if (op
->args
[0] != '\0')
681 (*info
->fprintf_func
) (info
->stream
, "\t");
683 for (s
= op
->args
; *s
!= '\0'; s
++)
687 && (((insn
>> MIPS16OP_SH_RX
) & MIPS16OP_MASK_RX
)
688 == ((insn
>> MIPS16OP_SH_RY
) & MIPS16OP_MASK_RY
)))
690 /* Skip the register and the comma. */
696 && (((insn
>> MIPS16OP_SH_RZ
) & MIPS16OP_MASK_RZ
)
697 == ((insn
>> MIPS16OP_SH_RX
) & MIPS16OP_MASK_RX
)))
699 /* Skip the register and the comma. */
703 print_mips16_insn_arg (*s
, op
, insn
, use_extend
, extend
, memaddr
,
707 if ((op
->pinfo
& INSN_UNCOND_BRANCH_DELAY
) != 0)
709 info
->branch_delay_insns
= 1;
710 if (info
->insn_type
!= dis_jsr
)
711 info
->insn_type
= dis_branch
;
719 (*info
->fprintf_func
) (info
->stream
, "0x%x", extend
| 0xf000);
720 (*info
->fprintf_func
) (info
->stream
, "0x%x", insn
);
721 info
->insn_type
= dis_noninsn
;
726 /* Disassemble an operand for a mips16 instruction. */
729 print_mips16_insn_arg (type
, op
, l
, use_extend
, extend
, memaddr
, info
)
731 const struct mips_opcode
*op
;
736 struct disassemble_info
*info
;
743 (*info
->fprintf_func
) (info
->stream
, "%c", type
);
748 (*info
->fprintf_func
) (info
->stream
, "%s",
749 mips16_reg_names
[((l
>> MIPS16OP_SH_RY
)
750 & MIPS16OP_MASK_RY
)]);
755 (*info
->fprintf_func
) (info
->stream
, "%s",
756 mips16_reg_names
[((l
>> MIPS16OP_SH_RX
)
757 & MIPS16OP_MASK_RX
)]);
761 (*info
->fprintf_func
) (info
->stream
, "%s",
762 mips16_reg_names
[((l
>> MIPS16OP_SH_RZ
)
763 & MIPS16OP_MASK_RZ
)]);
767 (*info
->fprintf_func
) (info
->stream
, "%s",
768 mips16_reg_names
[((l
>> MIPS16OP_SH_MOVE32Z
)
769 & MIPS16OP_MASK_MOVE32Z
)]);
773 (*info
->fprintf_func
) (info
->stream
, "%s", mips32_reg_names
[0]);
777 (*info
->fprintf_func
) (info
->stream
, "%s", mips32_reg_names
[29]);
781 (*info
->fprintf_func
) (info
->stream
, "$pc");
785 (*info
->fprintf_func
) (info
->stream
, "%s", mips32_reg_names
[31]);
789 (*info
->fprintf_func
) (info
->stream
, "%s",
790 mips32_reg_names
[((l
>> MIPS16OP_SH_REGR32
)
791 & MIPS16OP_MASK_REGR32
)]);
795 (*info
->fprintf_func
) (info
->stream
, "%s",
796 mips32_reg_names
[MIPS16OP_EXTRACT_REG32R (l
)]);
822 int immed
, nbits
, shift
, signedp
, extbits
, pcrel
, extu
, branch
;
834 immed
= (l
>> MIPS16OP_SH_RZ
) & MIPS16OP_MASK_RZ
;
840 immed
= (l
>> MIPS16OP_SH_RX
) & MIPS16OP_MASK_RX
;
846 immed
= (l
>> MIPS16OP_SH_RZ
) & MIPS16OP_MASK_RZ
;
852 immed
= (l
>> MIPS16OP_SH_RX
) & MIPS16OP_MASK_RX
;
858 immed
= (l
>> MIPS16OP_SH_IMM4
) & MIPS16OP_MASK_IMM4
;
864 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
865 info
->insn_type
= dis_dref
;
871 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
872 info
->insn_type
= dis_dref
;
878 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
879 if ((op
->pinfo
& MIPS16_INSN_READ_PC
) == 0
880 && (op
->pinfo
& MIPS16_INSN_READ_SP
) == 0)
882 info
->insn_type
= dis_dref
;
889 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
890 info
->insn_type
= dis_dref
;
895 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
900 immed
= (l
>> MIPS16OP_SH_IMM6
) & MIPS16OP_MASK_IMM6
;
904 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
909 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
910 /* FIXME: This might be lw, or it might be addiu to $sp or
911 $pc. We assume it's load. */
912 info
->insn_type
= dis_dref
;
918 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
919 info
->insn_type
= dis_dref
;
924 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
929 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
935 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
940 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
944 info
->insn_type
= dis_condbranch
;
948 immed
= (l
>> MIPS16OP_SH_IMM11
) & MIPS16OP_MASK_IMM11
;
952 info
->insn_type
= dis_branch
;
957 immed
= (l
>> MIPS16OP_SH_IMM8
) & MIPS16OP_MASK_IMM8
;
959 /* FIXME: This can be lw or la. We assume it is lw. */
960 info
->insn_type
= dis_dref
;
966 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
968 info
->insn_type
= dis_dref
;
974 immed
= (l
>> MIPS16OP_SH_IMM5
) & MIPS16OP_MASK_IMM5
;
983 if (signedp
&& immed
>= (1 << (nbits
- 1)))
986 if ((type
== '<' || type
== '>' || type
== '[' || type
== ']')
993 immed
|= ((extend
& 0x1f) << 11) | (extend
& 0x7e0);
994 else if (extbits
== 15)
995 immed
|= ((extend
& 0xf) << 11) | (extend
& 0x7f0);
997 immed
= ((extend
>> 6) & 0x1f) | (extend
& 0x20);
998 immed
&= (1 << extbits
) - 1;
999 if (! extu
&& immed
>= (1 << (extbits
- 1)))
1000 immed
-= 1 << extbits
;
1004 (*info
->fprintf_func
) (info
->stream
, "%d", immed
);
1013 baseaddr
= memaddr
+ 2;
1015 else if (use_extend
)
1016 baseaddr
= memaddr
- 2;
1024 /* If this instruction is in the delay slot of a jr
1025 instruction, the base address is the address of the
1026 jr instruction. If it is in the delay slot of jalr
1027 instruction, the base address is the address of the
1028 jalr instruction. This test is unreliable: we have
1029 no way of knowing whether the previous word is
1030 instruction or data. */
1031 status
= (*info
->read_memory_func
) (memaddr
- 4, buffer
, 2,
1034 && (((info
->endian
== BFD_ENDIAN_BIG
1035 ? bfd_getb16 (buffer
)
1036 : bfd_getl16 (buffer
))
1037 & 0xf800) == 0x1800))
1038 baseaddr
= memaddr
- 4;
1041 status
= (*info
->read_memory_func
) (memaddr
- 2, buffer
,
1044 && (((info
->endian
== BFD_ENDIAN_BIG
1045 ? bfd_getb16 (buffer
)
1046 : bfd_getl16 (buffer
))
1047 & 0xf81f) == 0xe800))
1048 baseaddr
= memaddr
- 2;
1051 val
= (baseaddr
& ~((1 << shift
) - 1)) + immed
;
1052 (*info
->print_address_func
) (val
, info
);
1061 l
= ((l
& 0x1f) << 23) | ((l
& 0x3e0) << 13) | (extend
<< 2);
1062 (*info
->print_address_func
) (((memaddr
+ 4) & 0xf0000000) | l
, info
);
1063 info
->insn_type
= dis_jsr
;
1064 info
->target
= ((memaddr
+ 4) & 0xf0000000) | l
;
1065 info
->branch_delay_insns
= 1;
1071 int need_comma
, amask
, smask
;
1075 l
= (l
>> MIPS16OP_SH_IMM6
) & MIPS16OP_MASK_IMM6
;
1077 amask
= (l
>> 3) & 7;
1079 if (amask
> 0 && amask
< 5)
1081 (*info
->fprintf_func
) (info
->stream
, "%s", mips32_reg_names
[4]);
1083 (*info
->fprintf_func
) (info
->stream
, "-%s",
1084 mips32_reg_names
[amask
+ 3]);
1088 smask
= (l
>> 1) & 3;
1091 (*info
->fprintf_func
) (info
->stream
, "%s??",
1092 need_comma
? "," : "");
1097 (*info
->fprintf_func
) (info
->stream
, "%s%s",
1098 need_comma
? "," : "",
1099 mips32_reg_names
[16]);
1101 (*info
->fprintf_func
) (info
->stream
, "-%s",
1102 mips32_reg_names
[smask
+ 15]);
1108 (*info
->fprintf_func
) (info
->stream
, "%s%s",
1109 need_comma
? "," : "",
1110 mips32_reg_names
[31]);
1114 if (amask
== 5 || amask
== 6)
1116 (*info
->fprintf_func
) (info
->stream
, "%s$f0",
1117 need_comma
? "," : "");
1119 (*info
->fprintf_func
) (info
->stream
, "-$f1");
1125 /* xgettext:c-format */
1126 (*info
->fprintf_func
)
1128 _("# internal disassembler error, unrecognised modifier (%c)"),
This page took 0.05406 seconds and 5 git commands to generate.