I am working on z390 (Don Higgins' software) fixes to the emulation of the DP
(divide decimal) instruction and have a question as to what signs are set for
the remainder.
Normally I would answer my own question by running sample programs, but I am
retired and do not have access to a mainframe.
The description of DP in the Principles of Operation (SA22-7832-12), p 8-7,
states that
"The sign of the quotient is determined by the rules of algebra. The sign of
the remainder has the same value as the dividend sign. These rules hold even
when the quotient or remainder is zero."
Reading the second sentence literally, I interpret it to say that if the
dividend has a sign of A hex, then the sign of the remainder will also be A hex
("has the same value"), not the preferred positive sign C hex. Similarly, if
the dividend has a sign of B hex, so will the remainder.
Question: How should the sentence be interpreted?
The Principles of Operation is written very carefully and precisely, so my
above interpretation seems to be the correct interpretation. However, I want to
be sure.
The remainder of the text here describes how I've been trying to interpret the
sentence using z390.
In order to see how z390 handles the signs, a short program that does some
divisions for (dividend,divisor) pairs having signs A,B,C,D (16 combinations)
was run on z390. Partial results:
*** Begin Dividend zero tests ***
QuoRem 000C000C Dividend 0000000B Divisor 002B
QuoRem 000C000C Dividend 0000000B Divisor 002D
QuoRem 000C000C Dividend 0000000B Divisor 002A
QuoRem 000C000C Dividend 0000000B Divisor 002C
...
QuoRem 000C000C Dividend 0000000A Divisor 002B
QuoRem 000C000C Dividend 0000000A Divisor 002D
QuoRem 000C000C Dividend 0000000A Divisor 002A
QuoRem 000C000C Dividend 0000000A Divisor 002C
...
*** Begin Dividend non-zero tests ***
QuoRem 002C001D Dividend 0000005B Divisor 002B
QuoRem 002C001D Dividend 0000005B Divisor 002D
QuoRem 002D001D Dividend 0000005B Divisor 002A
QuoRem 002D001D Dividend 0000005B Divisor 002C
...
QuoRem 002D001C Dividend 0000005A Divisor 002B
QuoRem 002D001C Dividend 0000005A Divisor 002D
QuoRem 002C001C Dividend 0000005A Divisor 002A
QuoRem 002C001C Dividend 0000005A Divisor 002C
...
QuoRem 002C000C Dividend 0000004B Divisor 002B
QuoRem 002C000C Dividend 0000004B Divisor 002D
QuoRem 002D000C Dividend 0000004B Divisor 002A
QuoRem 002D000C Dividend 0000004B Divisor 002C
...
QuoRem 002D000C Dividend 0000004A Divisor 002B
QuoRem 002D000C Dividend 0000004A Divisor 002D
QuoRem 002C000C Dividend 0000004A Divisor 002A
QuoRem 002C000C Dividend 0000004A Divisor 002C
...
Each line shows a (quotient,remainder), dividend, and divisor.
The dividend is zero in the first group. Note that z390 did not set the sign of
the remainder correctly in the first four lines -- bug. In the next four lines,
the sign of the remainder is set to C hex, which is not A hex, the sign of the
dividend. However, it is "correct" in that both are positive.
In the second group of output, there are 16 lines where the remainder is
non-zero and 16 lines where the remainder is zero. The non-zero remainders have
the preferred sign corresponding to the sign value of the dividend, not the
actual sign of the dividend. The zero remainders have the same problem as the
first group.
I need to decide how to correctly set the sign of the remainder, hence my
question posed earlier.
Thanks for any help.
Regards,
John Ganci
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN