+ if (c.opcode == 0)
+ return snprintf(buf, len, "nop ");
+
+ switch (c.i.op) {
+ case OP_SPECIAL:
+ return print_op_special(c, buf, len, flags_ptr, nb_flags);
+ case OP_REGIMM:
+ *flags_ptr = opcode_branch_flags;
+ *nb_flags = ARRAY_SIZE(opcode_branch_flags);
+ return snprintf(buf, len, "%s%s,0x%x",
+ regimm_opcodes[c.i.rt],
+ lightrec_reg_name(c.i.rs),
+ pc + 4 + ((s16)c.i.imm << 2));
+ case OP_J:
+ case OP_JAL:
+ *flags_ptr = opcode_branch_flags;
+ *nb_flags = ARRAY_SIZE(opcode_branch_flags);
+ return snprintf(buf, len, "%s0x%x",
+ std_opcodes[c.i.op],
+ (pc & 0xf0000000) | (c.j.imm << 2));
+ case OP_BEQ:
+ if (c.i.rs == c.i.rt) {
+ *flags_ptr = opcode_branch_flags;
+ *nb_flags = ARRAY_SIZE(opcode_branch_flags);
+ return snprintf(buf, len, "b 0x%x",
+ pc + 4 + ((s16)c.i.imm << 2));
+ }
+ fallthrough;
+ case OP_BNE:
+ case OP_BLEZ:
+ case OP_BGTZ:
+ *flags_ptr = opcode_branch_flags;
+ *nb_flags = ARRAY_SIZE(opcode_branch_flags);
+ return snprintf(buf, len, "%s%s,%s,0x%x",
+ std_opcodes[c.i.op],
+ lightrec_reg_name(c.i.rs),
+ lightrec_reg_name(c.i.rt),
+ pc + 4 + ((s16)c.i.imm << 2));
+ case OP_ADDI:
+ case OP_ADDIU:
+ case OP_SLTI:
+ case OP_SLTIU:
+ case OP_ANDI:
+ case OP_ORI:
+ case OP_XORI:
+ return snprintf(buf, len, "%s%s,%s,0x%04hx",
+ std_opcodes[c.i.op],
+ lightrec_reg_name(c.i.rt),
+ lightrec_reg_name(c.i.rs),
+ (u16)c.i.imm);
+
+ case OP_LUI:
+ return snprintf(buf, len, "%s%s,0x%04hx",
+ std_opcodes[c.i.op],
+ lightrec_reg_name(c.i.rt),
+ (u16)c.i.imm);
+ case OP_CP0:
+ return print_op_cp(c, buf, len, 0);
+ case OP_CP2:
+ return print_op_cp(c, buf, len, 2);
+ case OP_LB:
+ case OP_LH:
+ case OP_LWL:
+ case OP_LW:
+ case OP_LBU:
+ case OP_LHU:
+ case OP_LWR:
+ case OP_SB:
+ case OP_SH:
+ case OP_SWL:
+ case OP_SW:
+ case OP_SWR:
+ *flags_ptr = opcode_io_flags;
+ *nb_flags = ARRAY_SIZE(opcode_io_flags);
+ *is_io = true;
+ return snprintf(buf, len, "%s%s,%hd(%s)",
+ std_opcodes[c.i.op],
+ lightrec_reg_name(c.i.rt),
+ (s16)c.i.imm,
+ lightrec_reg_name(c.i.rs));
+ case OP_LWC2:
+ case OP_SWC2:
+ *flags_ptr = opcode_io_flags;
+ *nb_flags = ARRAY_SIZE(opcode_io_flags);
+ return snprintf(buf, len, "%s%s,%hd(%s)",
+ std_opcodes[c.i.op],
+ lightrec_reg_name(c.i.rt),
+ (s16)c.i.imm,
+ lightrec_reg_name(c.i.rs));
+ case OP_META_MOV:
+ return snprintf(buf, len, "move %s,%s",
+ lightrec_reg_name(c.r.rd),
+ lightrec_reg_name(c.r.rs));
+ case OP_META_EXTC:
+ return snprintf(buf, len, "extc %s,%s",
+ lightrec_reg_name(c.i.rt),
+ lightrec_reg_name(c.i.rs));
+ case OP_META_EXTS:
+ return snprintf(buf, len, "exts %s,%s",
+ lightrec_reg_name(c.i.rt),
+ lightrec_reg_name(c.i.rs));
+ case OP_META_MULT2:
+ case OP_META_MULTU2:
+ *flags_ptr = opcode_multdiv_flags;
+ *nb_flags = ARRAY_SIZE(opcode_multdiv_flags);
+ return snprintf(buf, len, "%s%s,%s,%s,%u",
+ mult2_opcodes[c.i.op == OP_META_MULTU2],
+ lightrec_reg_name(get_mult_div_hi(c)),
+ lightrec_reg_name(get_mult_div_lo(c)),
+ lightrec_reg_name(c.r.rs), c.r.op);