Log in

View Full Version : idiv!!!


riPPadoGG
February 2nd, 2002, 07:52
Hi All,
A basic asm Q..
idiv fails when divisor is not very smaller that dividend..
Assembly text books advise division by continuous subtraction in these cases.
Anyother way out??(No floating point ops)
cheers!!!!
doGG

HAPPY REVERSING!!!

DakienDX
February 2nd, 2002, 08:41
Hello riPPadoGG !

The problem exists not only with the IDiv function, but also with the Div function.

When using a "IDiv ECX", the 64-bit value in EDX:EAX is divided through the 32-bit value in ECX. The result is saved into EAX and the remainder into EDX. But if the result would get bigger than 32-bit, it wouldn't fit into EAX any more and therefore an expection 00h, division by 0, is generated.

I don't know what you want to divide through what, but you could look at some high-level-languages to see how they handle the division, else I could redirect you to BigNum libaries, but they need much time for dividing (because they use continuous subtraction) and need their own BigNum format for handling with numbers.

I don't know any other way out apart from doning it like you learned it in school before you had a calculator.

riPPadoGG
February 4th, 2002, 06:17
Thats it..
answer from you was more than sufficient..

I will code in C, Delphi and use inline asm whenever necessary..