Author Topic: Dos box - division 64 bit by 64 bit  (Read 9108 times)

uni.stop

  • Guest
Dos box - division 64 bit by 64 bit
« 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!

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Dos box - division 64 bit by 64 bit
« Reply #1 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/

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Dos box - division 64 bit by 64 bit
« Reply #2 on: June 21, 2013, 10:38:38 PM »
deleted
« Last Edit: February 25, 2022, 06:25:24 AM by nidud »

jcfuller

  • Member
  • **
  • Posts: 195
Re: Dos box - division 64 bit by 64 bit
« Reply #3 on: June 22, 2013, 12:41:26 AM »
Am I missing something here?
The topic says dosbox so I would assume 16bit assembly ???

James

Gunther

  • Member
  • *****
  • Posts: 4198
  • Forgive your enemies, but never forget their names
Re: Dos box - division 64 bit by 64 bit
« Reply #4 on: June 22, 2013, 12:46:19 AM »
James,

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
You have to know the facts before you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Dos box - division 64 bit by 64 bit
« Reply #5 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

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Dos box - division 64 bit by 64 bit
« Reply #6 on: June 22, 2013, 02:47:27 AM »
deleted
« Last Edit: February 25, 2022, 06:25:37 AM by nidud »

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Dos box - division 64 bit by 64 bit
« Reply #7 on: June 22, 2013, 05:16:33 AM »

Code: [Select]
    mov     rax,qwDividend
    xor     rdx,rdx
    div     qwDivisor

 :P

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Dos box - division 64 bit by 64 bit
« Reply #8 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.
Well Microsoft, here’s another nice mess you’ve gotten us into.

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Dos box - division 64 bit by 64 bit
« Reply #9 on: June 22, 2013, 10:30:37 PM »
long division is a good assembler exercise   :P