Floating-Point Division Example - HP 9835A Programming Manual

35 series desktop computer assembly development rom
Table of Contents

Advertisement

96
Arithmetic
Another aspect of dealing with thirteen-digit dividends is the count placed in B with each
execution of FDV. Since each overflow is a "successful" subtraction in the sense that is part of
a proper count of subtractions (at least until A is 0), then that subtraction must be counted, too.
The difficulty with this is that FDV does not count this last (overflowing) subtraction. The
solution obviously is to add 1 to the value in the B register each time FDV causes an overflow.
However, with the last overflow, being the "real" overflow, the 1 shouldn't be added in, so
after adding it in (during the loop), you have to subtract it back out again (after leaving the
loop). To further complicate matters, if you have a zero remainder, you have to add it right
back in again.
For example, if there happened to be three uses of FDV for a certain quotient digit, you form
the quotient digit as -
Q"
=
(B
+
1 ) \
+
(B
+
1)\
value after 1st
value after 2nd
use of FDV
use of FDV
+B\
value after final
use of FDV
If the same general situation produced a zero remainder, then the quotient digit is formed as -
Q"
=
(B
+
1 ) \
+
(B
+
1 ) \
+
(B
+
1 ) \
value after 1st
value after 2nd
value after final
use of FDV
use of FDV
use of FDV
Floating-Point Division Example
An example of a 13-digit division routine follows. The rules which it implements are -
1. Always increment the value returned in B after an FDV operation.
2. After incrementing B, check the contents of A. If non-zero, loop immediately, performing
no other tests or activities.
3. When a quotient digit has been found (Le., A is zero), check to see if the remainder is O.
If so, exit the division loop. Save the last digit found as part of the answer.
4. If the remainder is not 0, decrement the value of the last quotient digit found and save it
as part of the answer. Then add back the divisor to the remainder.

Advertisement

Table of Contents
loading

Table of Contents