Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void Multiply64(DecodedInstruction inst)
- {
- if (IsReserved(inst))
- {
- m_Exceptions |= ExceptionFlags.Reserved;
- return;
- }
- bool isUnsigned = (inst.Op.Flags & ExecutionFlags.Unsigned) == ExecutionFlags.Unsigned;
- ulong operandA = (ulong)ReadGPR(inst.Source);
- ulong operandB = (ulong)ReadGPR(inst.Target);
- /* MIPS document says no overflow exceptions, ever... */
- unchecked
- {
- /* Break the operands into four parts */
- ulong A_HI = (operandA >> 32);
- ulong A_LO = (uint)operandA;
- ulong B_HI = (operandB >> 32);
- ulong B_LO = (uint)operandB;
- ulong RESULT_LO = 0;
- ulong RESULT_HI = 0;
- if (!isUnsigned)
- {
- A_HI = (ulong)(int)(uint)A_HI;
- B_HI = (ulong)(int)(uint)B_HI;
- }
- /* Product parts */
- ulong P1 = A_LO * B_LO;
- ulong P2 = A_HI * B_LO;
- ulong P3 = A_LO * B_HI;
- ulong P4 = A_HI * B_HI;
- uint CARRY = (uint)(((P1 >> 32) + (uint)P2 + (uint)P3) >> 32);
- ulong TEMP = (P2 >> 32) + (P3 >> 32);
- if (!isUnsigned)
- {
- TEMP = (ulong)(int)(uint)TEMP;
- }
- RESULT_LO = P1 + (P2 << 32) + (P3 << 32);
- RESULT_HI = P4 + TEMP + CARRY;
- WriteHi(RESULT_HI);
- WriteLo(RESULT_LO);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement