diff --git a/m2c/arch_mips.py b/m2c/arch_mips.py index 7bd0ce23..23ad4a15 100644 --- a/m2c/arch_mips.py +++ b/m2c/arch_mips.py @@ -871,7 +871,7 @@ def normalize_instruction(cls, instr: AsmInstruction) -> AsmInstruction: return AsmInstruction("li", [args[0], lit]) if instr.mnemonic == "jalr" and args[0] != Register("ra"): raise DecompFailure("Two-argument form of jalr is not supported.") - if instr.mnemonic in ("mult", "multu", "dmult", "dmultu", "madd", "maddu"): + if instr.mnemonic in ("mult", "multu", "dmult", "dmultu", "madd", "maddu", "msub", "msubu"): return AsmInstruction(instr.mnemonic, [Register("zero"), *args]) if instr.mnemonic in LENGTH_THREE: return cls.normalize_instruction( @@ -1177,7 +1177,7 @@ def eval_fn(s: NodeState, a: InstrArgs) -> None: and isinstance(args[2], Register) ) inputs = [args[1], args[2]] - if mnemonic in ("madd", "maddu"): + if mnemonic in ("madd", "maddu", "msub", "msubu"): inputs.append(Register("lo")) outputs = [Register("hi"), Register("lo")] if args[0] != Register("zero"): @@ -1441,6 +1441,24 @@ def eval_fn(s: NodeState, a: InstrArgs) -> None: a, ), ), + "msub": lambda a: ( + ErrorExpr("msub top half"), + handle_add_real( + Register("lo"), + a.regs[Register("lo")], + UnaryOp("-", BinaryOp.int(a.reg(1), "*", a.reg(2))), + a, + ), + ), + "msubu": lambda a: ( + ErrorExpr("msubu top half"), + handle_add_real( + Register("lo"), + a.regs[Register("lo")], + UnaryOp("-", BinaryOp.int(a.reg(1), "*", a.reg(2))), + a, + ), + ), } instrs_destination_first: InstrMap = { # Flag-setting instructions