That makes sense.
I'm not a math person myself, so I am strugling with the
logic behind it. But I have executed some experimental code
based on your example and it seems to work fine.
100.000/10 gives 10.000 if you now look at the
three zeros afther the dot then that is the ax register
and the 100 is the dx register.
by dividing you see that afther the division ax can't hold the whole 10.000.
so when you divide the 100.000 by 200 it gives .500 and that can be holded in ax.
try it with dividing by 100 and the result will be 1.000
with is just 1 to much to hold since the maximum in this
exxample is 999
I hope this explaince the arithmetic behind it a bit.
it's a bit clearer now, I could not understand what the
relationship between dx and bx was, and why bx should be
greater than dx in order to divide without an overflow.
But it can be explained by dividing the high order word
of a 32 bit dividend (dx:ax) with a 16 bit value (bx).
So let's leave out ax and concentrate on dx only:
; dx div bx
2 div 1 = 1 ;overflow.
2 div 2 = 1 ;overflow.
2 div 3 = 0 ;no overflow (quotient fits in 16 bit).
btw, I think this error checking code (for me at least) is
a bit clearer:
I never understood why Mr Intel thought that you could divide a 32-bit number by a 16-bit and come up with a 16-bit result. Did he think that division is the inverse of multpiplication and 16-bit x 16-bit yields 32 bit, or did he just run out of registers?
It is rather common to use this method, that stems from
the time computers had a huged lag of memory.
If you want to calculate the mean value of a lot of
numbers, as for administration purposes, you add up the
numbers in the double register set and then divide it by
the number count.
In this way you can add 64k numbers of a maximum of 64k
and it will still fit into the final calculation.
Then you can also use the remainder the refine your
outcom to as mutch decimal digits as needed.
So 100 times 30.000 will fit in the dx:ax pair and the result of 30.000 times 100 divide by 100 will still represent the correct answer.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.