ADD DECIMAL
AP [S5]
'FA' I L, I L, I B, I I B, I o 8 12 16 20 32 36 47
The second operand is added to the first
operand, and the resulting sum is placed
at the first-operand location. The
operands and result are in the packed
format.
Addition is algebraic, taking into
account the signs and all digits of both
operands. All sign and digit codes are
checked for validity.
If the first operand is too short to
contain all leftmost nonzero digits of
the sum, decimal overflow occurs. The
operation is completed. The result;s
obtained by ignoring the overflow
digits, and condition code 3 is set. If
the decimal-overflow mask is one, a
program interruption for decimal over­
flow occurs.
The sign of the sum is determined by the
rules of algebra. In the absence of
overflow, the sign of a zero result is
made positive. If overflow occurs, a
zero result is given either a positive
or negative sign, as determined by what
the sign of the correct sum would have
been.
Resulting Condition Code: o Result zero; no overflow
1 Result less than zero; no over­
flow
2 Result greater than zero; no
overflow 3 Overflow Program Exceptions:
Access (fetch, operand 2; fetch and
store, operand 1)
Data
Decimal overflow Programming Note
An example of the use of the ADD DECIMAL
instruction is given in Appendix A. COMPARE DECIMAL CP [S5]
'F9' I L, I L, I B, I B, I o 8 12 16 20 32 36 47
The first operand is compared with the
second operand, and the result is indi­
cated in the condition code. The oper­
ands are in the packed format.
Comparison is algebraic and follows the
procedure for decimal subtraction,
except that both operands remain
unchanged. When the difference ;s zero,
the operands are equal. When a nonzero
difference is positive or negative, the
first operand is high or low, respec­
tively.
Overflow cannot occur
difference is discarded.
because the
All sign and digit codes are checked for
validity.
Resulting Condition Code: o Operands equal
1 First operand low
2 First operand high
3 Program Exceptions:
Access (fetch, operands 1 and 2)
Data Programming Notes
1. An example of the use of the COMPARE DECIMAL instruction is
given in Appendix A.
2. The preferred and alternate sign
codes for a particular sign are
treated as equivalent for compar­
ison purposes.
3. A negative zero and a positive zero
compare equal.
DIVIDE DECIMAL DP [55)
'FD' I L, I L, I B, I I B, I o 8 12 16 20 32 36 47
The first operand (the dividend) is
divided by the second operand (the divi­
sor). The resulting quotient and Chapter 8. Decimal Instructions 8-5
remainder are placed at the first­
operand location. The operands and
results are in the packed format.
The quotient is placed leftmost in the
first-operand location. The number of
bytes in the quotient field is equal to
the difference between the dividend and
divisor lengths (ll - l2). The remain­
der is placed rightmost in the first­
operand location and has a length equal
to the divisor length. Together, the
quotient and remainder fields occupy the
entire first operand; therefore, the
address of the quotient is the address
of the first operand.
The divisor length cannot exceed 15
digits and sign (l2 not greater than
seven) and must be less than the divi­
dend length (l2 less than L l ); otherwise, a specification exception is recognized.
The dividend, divisor, quotient, and
remainder are each signed decimal inte­
gers in the packed format and are
right-aligned in their fields. All sign
and digit codes of the dividend and
divisor are checked for validity.
The sign of the quotient is determined
by the rules of algebra from the divi­
dend and divisor signs. The sign of the
remainder has the same value as the
dividend sign. These rules hold even
when the quotient or remainder is zero.
Overflow cannot occur. If the divisor is zero or the quotient is too large to
be represented by the number of digits
specified, a decimal-divide exception is
recognized. This includes the case of
division of zero by zero. The decimal­
divide exception is indicated only if the sign codes of both the dividend and
divisor are valid, and only if the digit
or digits used in establishing the
exception are valid.
Condition Code:
unchanged.
Program Exceptions:
The code remains
Access (fetch, operand 2; fetch and
store, operand 1)
Data
Decimal divide
Specification
Programming Notes
1. An example of the use of the DIVIDE
DECIMAL instruction is given in
Appendix A.
2. The dividend cannot exceed 31
digits and sign. Since the remain­
der cannot be shorter than one
8-6 System/370 -Principles of Operation digit and sign, the quotient cannot
exceed 29 digits and sign.
3. The condition for a decimal-divide
exception can be determined by a
trial comparison. The leftmost
digit of the divisor is aligned one
digit to the right of the leftmost
dividend digit. When the divisor,
so aligned, is less than or equal
to the dividend, ignoring signs, a
divide exception is indicated.
4. If a data exception does not exist,
a decimal-divide exception occurs
when the leftmost dividend digit is
not zero.
EDIT
ED [55] ___ I B, I o 8 16 20 32 36 47
The second operand (the source), which
normally contains one or more decimal
numbers in the packed format, is changed
to the zoned format and modified under
the control of the first operand (the
pattern). The edited result replaces
the first operand.
The length field specifies the length of
the first operand, which may contain
bytes of any value.
The length of the source is determined
by the operation according to the
contents of the pattern. The source
normally consists of one or more decimal
numbers, each in the packed format. The
leftmost four bits of each source byte
must specify a decimal-digit code (0000-1001); a slgn code (1010-1111) is recognized as a data exception. The
rightmost four bits may specify either a
sign code or a decimal-digit code.
Access and data exceptions are recog­
nized only for those bytes in the second
operand which are actually required. The result is obtained as if both oper­
ands were processed left to right one
byte at a time. Overlapping pattern and
source fields give unpredictable
results.
During the editing process, each byte of
the pattern is affected in one of three
ways:
1. It is left unchanged.
2. It is replaced by a source digit
expanded to the zoned format.
3. It is replaced by the first byte in
the pattern, called the fill byte.
Previous Page Next Page