-int
-print_insn_msp430 (addr, info)
- bfd_vma addr;
- disassemble_info *info;
-{
- void *stream = info->stream;
- fprintf_ftype prin = info->fprintf_func;
- struct msp430_opcode_s *opcode;
- char op1[32], op2[32], comm1[64], comm2[64];
- int cmd_len = 0;
- unsigned short insn;
- int cycles = 0;
- char *bc = "";
- char dinfo[32]; /* Debug purposes. */
-
- insn = msp430dis_opcode (addr, info);
- sprintf (dinfo, "0x%04x", insn);
-
- if (((int) addr & 0xffff) > 0xffdf)
- {
- (*prin) (stream, "interrupt service routine at 0x%04x", 0xffff & insn);
- return 2;
- }
-
- *comm1 = 0;
- *comm2 = 0;
-
- for (opcode = msp430_opcodes; opcode->name; opcode++)
- {
- if ((insn & opcode->bin_mask) == opcode->bin_opcode
- && opcode->bin_opcode != 0x9300)
- {
- *op1 = 0;
- *op2 = 0;
- *comm1 = 0;
- *comm2 = 0;
-
- /* r0 as destination. Ad should be zero. */
- if (opcode->insn_opnumb == 3 && (insn & 0x000f) == 0
- && (0x0080 & insn) == 0)
- {
- cmd_len =
- msp430_branchinstr (info, opcode, addr, insn, op1, comm1,
- &cycles);
- if (cmd_len)
- break;
- }
-
- switch (opcode->insn_opnumb)
- {
- case 0:
- cmd_len = msp430_nooperands (opcode, addr, insn, comm1, &cycles);
- break;
- case 2:
- cmd_len =
- msp430_doubleoperand (info, opcode, addr, insn, op1, op2,
- comm1, comm2, &cycles);
- if (insn & BYTE_OPERATION)
- bc = ".b";
- break;
- case 1:
- cmd_len =
- msp430_singleoperand (info, opcode, addr, insn, op1, comm1,
- &cycles);
- if (insn & BYTE_OPERATION && opcode->fmt != 3)
- bc = ".b";
- break;
- default:
- break;
- }
- }
-
- if (cmd_len)
- break;
- }
-
- dinfo[5] = 0;
-
- if (cmd_len < 1)
- {
- /* Unknown opcode, or invalid combination of operands. */
- (*prin) (stream, ".word 0x%04x; ????", PS (insn));
- return 2;
- }
-
- (*prin) (stream, "%s%s", opcode->name, bc);
-
- if (*op1)
- (*prin) (stream, "\t%s", op1);
- if (*op2)
- (*prin) (stream, ",");
-
- if (strlen (op1) < 7)
- (*prin) (stream, "\t");
- if (!strlen (op1))
- (*prin) (stream, "\t");
-
- if (*op2)
- (*prin) (stream, "%s", op2);
- if (strlen (op2) < 8)
- (*prin) (stream, "\t");
-
- if (*comm1 || *comm2)
- (*prin) (stream, ";");
- else if (cycles)
- {
- if (*op2)
- (*prin) (stream, ";");
- else
- {
- if (strlen (op1) < 7)
- (*prin) (stream, ";");
- else
- (*prin) (stream, "\t;");
- }
- }
- if (*comm1)
- (*prin) (stream, "%s", comm1);
- if (*comm1 && *comm2)
- (*prin) (stream, ",");
- if (*comm2)
- (*prin) (stream, " %s", comm2);
- return cmd_len;
-}
-
-int
-msp430_nooperands (opcode, addr, insn, comm, cycles)
- struct msp430_opcode_s *opcode;
- bfd_vma addr ATTRIBUTE_UNUSED;
- unsigned short insn ATTRIBUTE_UNUSED;
- char *comm;
- int *cycles;