[Mono-list] Integer division problems
Dietmar Maurer
dietmar@ximian.com
Sun, 10 Mar 2002 10:00:05 +0100
Martin Baulig wrote:
> Dietmar Maurer <dietmar@ximian.com> writes:
>
> > No, there is something wrong! I use CDQ to sign extend to 64bit in EAX/EDX,
> > so I assume your code is right for DIV_UN (althought you should remove that
> > unnecessary CDQ then), but DIV should work the way it is?
>
> Yes, I was confused. For DIV_UN, the CDQ is wrong since it sets EDX to -1 if
> EAX is "negative", but we're performing an unsigned division.
>
> DIV works the way it is and does not any longer with my patch.
>
> Here's the corrected patch:
>
> ====
> 2002-03-09 Martin Baulig <martin@gnome.org>
>
> * x86.brg (DIV_UN): Clear EDX before performing the division and remove
> the unnecessary CDQ instruction.
>
> =====
>
> ------------------------------------------------------------------------
>
> dietmar-diff.txtName: dietmar-diff.txt
> Type: Plain Text (text/plain)
>
> ------------------------------------------------------------------------
>
> Ok this time ?
Yes, looks fine - please commit.
- Dietmar