@@ -796,7 +796,7 @@ static void SignExtendHiLo(LowLevelILFunction& il, size_t registerSize)
796796 }
797797}
798798
799- bool GetLowLevelILForInstruction (Architecture* arch, uint64_t addr, LowLevelILFunction& il, Instruction& instr, size_t addrSize, uint32_t decomposeFlags)
799+ bool GetLowLevelILForInstruction (Architecture* arch, uint64_t addr, LowLevelILFunction& il, Instruction& instr, size_t addrSize, uint32_t decomposeFlags, MipsVersion version )
800800{
801801 LowLevelILLabel trueLabel, falseLabel, doneLabel, dirFlagSet, dirFlagClear, dirFlagDone;
802802 InstructionOperand& op1 = instr.operands [0 ];
@@ -1179,15 +1179,61 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
11791179 SignExtendHiLo (il, registerSize);
11801180 break ;
11811181 case MIPS_MULT:
1182- il.AddInstruction (il.SetRegisterSplit (4 , REG_HI, REG_LO, il.MultDoublePrecSigned (4 , ReadILOperand (il, instr, 1 , registerSize), ReadILOperand (il, instr, 2 , registerSize))));
1183- SignExtendHiLo (il, registerSize);
1184- if (rd != REG_ZERO)
1185- // mflo
1186- il.AddInstruction (SetRegisterOrNop (il, registerSize, registerSize, rd, il.Register (registerSize, REG_LO)));
1182+ if (version == MIPS_R5900 && instr.numOperands == 3 ) {
1183+ auto temp = LLIL_TEMP (0 );
1184+ il.AddInstruction (il.SetRegister (8 , temp,
1185+ il.MultDoublePrecSigned (4 ,
1186+ ReadILOperand (il, instr, 2 , registerSize),
1187+ ReadILOperand (il, instr, 3 , registerSize))));
1188+ il.AddInstruction (il.SetRegister (registerSize, REG_HI, il.SignExtend (8 , il.ArithShiftRight (8 , il.Register (8 , temp), il.Const (8 , 32 )))));
1189+ il.AddInstruction (il.SetRegister (registerSize, REG_LO, il.SignExtend (8 , il.LowPart (4 , il.Register (8 , temp)))));
1190+ // il.AddInstruction(il.SetRegisterSplit(4, REG_HI, REG_LO,
1191+ // il.MultDoublePrecSigned(8,
1192+ // ReadILOperand(il, instr, 2, registerSize),
1193+ // ReadILOperand(il, instr, 3, registerSize))));
1194+ SignExtendHiLo (il, registerSize);
1195+ auto rd = op1.reg ;
1196+ if (rd != REG_ZERO)
1197+ il.AddInstruction (SetRegisterOrNop (il, registerSize, registerSize, rd, il.Register (registerSize, REG_LO)));
1198+ }
1199+ // if (version == MIPS_R5900 && instr.numOperands == 3) {
1200+ // il.AddInstruction(il.SetRegisterSplit(4, REG_HI, REG_LO,
1201+ // il.MultDoublePrecSigned(8,
1202+ // ReadILOperand(il, instr, 2, registerSize),
1203+ // ReadILOperand(il, instr, 3, registerSize))));
1204+ // SignExtendHiLo(il, registerSize);
1205+ // auto rd = op1.reg;
1206+ // if (rd != REG_ZERO)
1207+ // il.AddInstruction(SetRegisterOrNop(il, registerSize, registerSize, rd, il.Register(registerSize, REG_LO)));
1208+ // }
1209+ else
1210+ {
1211+ il.AddInstruction (il.SetRegisterSplit (4 , REG_HI, REG_LO,
1212+ il.MultDoublePrecSigned (4 ,
1213+ ReadILOperand (il, instr, 1 , registerSize),
1214+ ReadILOperand (il, instr, 2 , registerSize))));
1215+ SignExtendHiLo (il, registerSize);
1216+ }
11871217 break ;
11881218 case MIPS_MULTU:
1189- il.AddInstruction (il.SetRegisterSplit (4 , REG_HI, REG_LO, il.MultDoublePrecUnsigned (4 , ReadILOperand (il, instr, 1 , registerSize), ReadILOperand (il, instr, 2 , registerSize))));
1190- SignExtendHiLo (il, registerSize);
1219+ if (version == MIPS_R5900 && instr.numOperands == 3 ) {
1220+ il.AddInstruction (il.SetRegisterSplit (4 , REG_HI, REG_LO,
1221+ il.MultDoublePrecUnsigned (4 ,
1222+ ReadILOperand (il, instr, 2 , registerSize),
1223+ ReadILOperand (il, instr, 3 , registerSize))));
1224+ SignExtendHiLo (il, registerSize);
1225+ auto rd = op1.reg ;
1226+ if (rd != REG_ZERO)
1227+ il.AddInstruction (SetRegisterOrNop (il, registerSize, registerSize, rd, il.Register (registerSize, REG_LO)));
1228+ }
1229+ else
1230+ {
1231+ il.AddInstruction (il.SetRegisterSplit (4 , REG_HI, REG_LO,
1232+ il.MultDoublePrecUnsigned (4 ,
1233+ ReadILOperand (il, instr, 1 , registerSize),
1234+ ReadILOperand (il, instr, 2 , registerSize))));
1235+ SignExtendHiLo (il, registerSize);
1236+ }
11911237 break ;
11921238 case MIPS_DMULT:
11931239 il.AddInstruction (il.SetRegisterSplit (8 , REG_HI, REG_LO, il.MultDoublePrecSigned (8 , ReadILOperand (il, instr, 1 , registerSize), ReadILOperand (il, instr, 2 , registerSize))));
0 commit comments