The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: uni.stop on June 21, 2013, 04:56:10 AM

Title: Dos box - division 64 bit by 64 bit
Post by: uni.stop on June 21, 2013, 04:56:10 AM
Hello,
I'm new here and I don't know if it is the right place to post my problem.

How can I implement 64 bit by 64 bit division in Assembly 8086?
I have already enabled extendeed registers with .386 directive.

Thanks!
Title: Re: Dos box - division 64 bit by 64 bit
Post by: dedndave on June 21, 2013, 06:54:32 AM
well - when you multiply a 32-bit value by another 32-bit value, you end up with as many as 64 bits
the opposite holds true when you divide - sort of   :P

but - the easy answer is to use the FPU
80-bit reals (extended reals) have 64-bits of precision

Ray has a nice tutorial to get you started, as well as a lib and some examples...

http://www.ray.masmcode.com/ (http://www.ray.masmcode.com/)
Title: Re: Dos box - division 64 bit by 64 bit
Post by: nidud on June 21, 2013, 10:38:38 PM
deleted
Title: Re: Dos box - division 64 bit by 64 bit
Post by: jcfuller on June 22, 2013, 12:41:26 AM
Am I missing something here?
The topic says dosbox so I would assume 16bit assembly ???

James
Title: Re: Dos box - division 64 bit by 64 bit
Post by: Gunther on June 22, 2013, 12:46:19 AM
James,

Quote from: jcfuller on June 22, 2013, 12:41:26 AM
Am I missing something here?
The topic says dosbox so I would assume 16bit assembly ???

the entire thing is a bit more tricky, because the thread is inside the 64 bit forum. Let's see what the thread starter has to say.

Gunther
Title: Re: Dos box - division 64 bit by 64 bit
Post by: dedndave on June 22, 2013, 01:34:36 AM
you can use 32-bit instructions in 16-bit code   :P

the real question is - what size is the divisor
larger dividends/quotients is easy enough
Title: Re: Dos box - division 64 bit by 64 bit
Post by: nidud on June 22, 2013, 02:47:27 AM
deleted
Title: Re: Dos box - division 64 bit by 64 bit
Post by: dedndave on June 22, 2013, 05:16:33 AM

    mov     rax,qwDividend
    xor     rdx,rdx
    div     qwDivisor


:P
Title: Re: Dos box - division 64 bit by 64 bit
Post by: MichaelW on June 22, 2013, 05:34:43 PM
This seems like an unreasonably difficult assignment for anyone new to programming. The Microsoft RTL function that does this was apparently coded in inline assembly in a naked function, using ~70 32-bit instructions.
Title: Re: Dos box - division 64 bit by 64 bit
Post by: dedndave on June 22, 2013, 10:30:37 PM
long division is a good assembler exercise   :P