Hi I recently noticed that the compiler (at least the 2.3.8 Linux version for Intel) now attempts to compensate for fractions when performing signed integer division, adjusting the result returned by the CPU. This requires a minimum of three additional instructions and can create problems when routines are written in assembler since the result will deviate in some cases from what Oberon says the answer should be. Does anyone know what the reasoning behind this change was? Previously, something like x DIV y (with x, y: LONGINT) would result in MOV EAX, x[EBP] CDQ IDIV y[EBP] but now, the compiler generates MOV EAX, x[EBP] CDQ IDIV y[EBP] CMP EDX, 0 JGE done DEC EAX done: Regards Jacques Eloff
Hi Jacques, I'm not sure, as this happened quite a long time ago. I can only find a log entry on 01.08.02: "Better code pattern for DIV", but the diff of the code shows that this behavious was already in the compiler: http://www.oberon.ethz.ch/cgi-bin/cvsweb.cgi/OP2/OPL.Mod.diff?r1=1.35&r2=1.3 6 I remember a few complaints that the compiler did not behave as requested by the language report for negative values. Maybe this is the fix for that? The JGE/DEC code is in the compiler at least from June 2000 (when I started archiving the sources with CVS). Obviously it takes time for the code to flow in all ports. -Patrik
Hi
I recently noticed that the compiler (at least the 2.3.8 Linux version for Intel) now attempts to compensate for fractions when performing signed integer division, adjusting the result returned by the CPU. This requires a minimum of three additional instructions and can create problems when routines are written in assembler since the result will deviate in some cases from what Oberon says the answer should be. Does anyone know what the reasoning behind this change was?
Previously, something like x DIV y (with x, y: LONGINT) would result in
MOV EAX, x[EBP] CDQ IDIV y[EBP]
but now, the compiler generates
MOV EAX, x[EBP] CDQ IDIV y[EBP] CMP EDX, 0 JGE done DEC EAX done:
Regards Jacques Eloff -- Oberon@inf.ethz.ch mailing list for ETH Oberon and related systems http://www.lists.inf.ethz.ch/mailman/listinfo/oberon
participants (2)
-
Jacques Eloff -
Patrik Reali