How can i divide two 64-bits integers?

(if anyone have a bunch of macros or procs to simplify the task of working with 64-bits numbers, please send me a copy)

/delight

(if anyone have a bunch of macros or procs to simplify the task of working with 64-bits numbers, please send me a copy)

/delight

Ok heres the deal, havent checked this, but it should work:

(surprised it took 45 odd readings and still no responce)

The remainder is now in ..

Hope this helps, there is no faster way than itteration when you have 64 bits, PLUS, the extra confusion of a 64 bit denominator.

Hope this helps..

:alright:

NaN

(surprised it took 45 odd readings and still no responce)

```
```

.data?

ah32 dd ? ; upper 63-32 bits of numerator

al32 dd ? ; lower 31-0 bits

bh32 dd ? ; upper 63-32 of denominator

bl32 dd ? ; lower 31-0

Quotient dd ?

.code

xor ecx, ecx

mov eax, ah32

@@:

.if( eax == bh32 )

mov eax, al32

.if( eax < bl32 )

jmp @F

.endif

.elseif (eax < bh32 )

jmp @f

.endif

mov eax, al32

mov edx, bl32

sub eax, edx

mov al32, eax

mov eax, ah32

mov edx, bh32

sbb eax, edx

mov ah32, eax

inc ecx

jmp @B

@@:

mov Quotient, ecx

The remainder is now in ..

Hope this helps, there is no faster way than itteration when you have 64 bits, PLUS, the extra confusion of a 64 bit denominator.

Hope this helps..

:alright:

NaN

Hello !

You can do this divide with the fpu:

In Val3 (as 64 Bit) will be stored the result of the division of Val1 by Val2 (both as 64 bit-integers loaded)

Greetings, CALEB

You can do this divide with the fpu:

```
```

fild qword ptr [Val1]

fild qword ptr [Val2]

fdivrp st(1), st

fistp qword ptr [Val3]

In Val3 (as 64 Bit) will be stored the result of the division of Val1 by Val2 (both as 64 bit-integers loaded)

Greetings, CALEB

Doh! Doh! DOh! :)

I should really practice more floating point, i forgot all about the QWORD... ((( DOH! )))

NaN

I should really practice more floating point, i forgot all about the QWORD... ((( DOH! )))

NaN

Thanks guys!

I must admit that Nan's version looks a little complicated compared to Calebs, but don't worry, I'll try your code too Nan... :rolleyes:

:alright:

/Delight

I must admit that Nan's version looks a little complicated compared to Calebs, but don't worry, I'll try your code too Nan... :rolleyes:

:alright:

/Delight