Skip to content

Commit

Permalink
Fix int64 divide.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 7, 2015
1 parent 959732f commit 63d83a6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions source/Cosmos.IL2CPU/IL/Div.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 4 };

// pop both 8 byte values
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 16 };
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 };

//dividend
// low
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 8 };
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true };
//high
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 12 };
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 4 };

new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 };

// set flags
new CPUx86.Or { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI };
Expand Down Expand Up @@ -91,7 +93,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )

// sign extend
new CPUx86.SignExtendAX { Size = 32 };

// save result to stack
new CPUx86.Push { DestinationReg = CPUx86.Registers.EDX };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
Expand Down Expand Up @@ -140,4 +142,4 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
}
}
}
}
}

0 comments on commit 63d83a6

Please sign in to comment.