[Mono-list] Integer division problems
Martin Baulig
martin@gnome.org
10 Mar 2002 02:22:50 +0100
--=-=-=
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.
=====
--=-=-=
Content-Disposition: attachment; filename=dietmar-diff.txt
Index: x86.brg
===================================================================
RCS file: /cvs/public/mono/mono/jit/x86.brg,v
retrieving revision 1.92
diff -u -u -r1.92 x86.brg
--- x86.brg 2002/03/08 06:08:46 1.92
+++ x86.brg 2002/03/09 21:13:31
@@ -816,7 +816,7 @@
if (tree->left->reg1 != X86_EAX)
x86_mov_reg_reg (s->code, X86_EAX, tree->left->reg1, 4);
- x86_cdq (s->code);
+ x86_mov_reg_imm (s->code, X86_EDX, 0);
x86_div_reg (s->code, tree->right->reg1, FALSE);
mono_assert (tree->reg1 == X86_EAX &&
Index: ChangeLog
===================================================================
RCS file: /cvs/public/mono/mono/jit/ChangeLog,v
retrieving revision 1.121
diff -u -u -r1.121 ChangeLog
--- ChangeLog 2002/03/08 06:08:46 1.121
+++ ChangeLog 2002/03/09 21:13:31
@@ -1,3 +1,7 @@
+2002-03-09 Martin Baulig <martin@gnome.org>
+
+ * x86.brg (DIV_UN): Clear EDX before performing the division.
+
2002-03-07 Dietmar Maurer <dietmar@ximian.com>
* jit.c (mono_analyze_stack): only load addresses of value types
--=-=-=
Ok this time ?
--
Martin Baulig
martin@gnome.org
--=-=-=--