Addition is algebraic, taking into account sign and
all digits of both operands. All signs and digits are
checked for validity. If necessary, high-order zeros are
supplied for either operand. When the first operand
field is too short to contain all significant digits of the
sum, a decimal overflow occurs, and a program inter­
ruption is taken provided that the corresponding mask
bit is one. Overflow has two possible causes. The first is the
loss of a carry out of the high-order digit position of
the result field. The second cause is an oversized re­
sult, which occurs when the second operand field is
larger than the first operand field and significant result
digits are lost. The field sizes alone are not an indi­
cation of overflow.
The first and second operand fields may overlap
when their low-order bytes coincide; therefore, it is
possible to add a number to itself.
The sign of the result is determined by the rules of
algebra. A zero sum is always positive. When high­
order digits are lost because of overflow, a zero result
has the sign of the correct sum.
Resulting Condition Code:
o Sum is zero
1 Sum is less than zero
2 Sum is greater than zero
3 Overflow Program Interruptions: Operation (if decimal feature is not installed)
Protection
Addressing
Data Overflow Subtract [»ecimal 5P 55
FB
78 11 12 1516
The second operand is subtracted from the first oper­
and, and the difference is placed in the first operand
location.
Subtraction is algebraic, taking into account sign
and all digits of both operands. The SUBTRACf DECIMAL
is similar to ADD DECIMAL, except that the sign of the
second operand is changed from positive to negative
or from negative to positive after the operand is ob­
tained from storage and before the arithmetic.
The sign of the result is determined by the rules of
algebra. A zero difference is always positive. When
36
high-order digits are lost because of overflow, a zero
result has the sign of the correct difference. Resulting. Condition Code:
o Difference is zero
1 Difference is less than zero
2 Difference is greater than zero
3 Overflow Program Interruptions: Operation (if decimal feature is not installed)
Protection
Addressing
Data
Decimal overflow
Programming Note
The operands of SUBTRACT DECIMAL may overlap when
their low-order bytes coincide, even when their
lengths are unequal. This property may be used to set
to zero an entire field or the low-order part of a ReId. Zero and Add ZAP 55 F8
78 11 12 1516
The second operand is placed in the first operand lo­
cation.
The operation is equivalent to an addition to zero.
A zero result is positive. When high-order digits are
lost because of overflow, a zero result has the sign of
the second operand. Only the second operand is checked for valid sign
and digit codes. Extra high-order zeros are supplied
if needed. When the Rrst operand Reld is too short to
contain all significant digits of the second operand, a
decimal overflow occurs and results in a program in­
terruption, provided that the decimal overflow mask
bit is one. The Rrst and second operand fields may
overlap when the rightmost byte of the first operand
field is coincident with or to the right of the rightmost
byte of the second operand.
Resulting Condition Code:
o Result is zero
1 Result is less than zero
2 Result is greater than zero
3 Overflow Program Interruptions: Operation (if decimal feature is not installed)
Addressing
Data
Decimal overflow
Protection
Compare Decimal CP 55 F9
B1 I D1 I B2 IJ[5J 7 8 11 12 1516 1920 3132 35 36 47 The first operand is compared with the second, and
the condition code indicates the comparison result.
Comparison is right to left, taking into account the
sign and all digits of both operands. All signs and
digits are checked for validity. If the fields are un­
equal in length, the shorter is extended with high­
order zeros. A positive zero compares equal to a nega­
tive zero. Neither operand is changed as a result of
the operation. Overflow cannot occur in this operation.
The first and second fields may overlap when their
low-order bytes coincide. It is possible, therefore, to
compare a number to itself.
Resulting Condition Code:
o Operands equal
1 First operand is low
2 First operand is high
3
Program Interruptions:
Operation (if decimal feature is not installed)
Addressing
Data
Programming Note
The COMPARE DECIMAL is unique in processing from
right to left; taking signs, zeros, and invalid characters
into account; and extending variable-length fields
when they are unequal in length. Multiply Decimal MP 55 Fe
78 11 12 1516
The product of the multiplier (the second operand)
and the multiplicand (the first operand) replaces the
multiplicand.
The multiplier size is limited to 15 digits and sign
and must be less than the multiplicand size. Length
code L2, larger than seven, or larger than or equal to
the length code Ll, is recognized as a specification ex­
ception. The operation is suppressed and a program
interruption occurs. Since the number of digits in the product is the sum
of the number of digits in the operands, the multi­
plicand must have high-order zero digits for at least
a field size that equals the multiplier field size; other-
wise, a data exception is recognized, and a program
interruption occurs. This definition of the multiplicand
field ensures that no product overflow can occur. The
maximum product size is 31 digits. At least one high­
order digit of the product field is zero.
All operands and results are treated as signed in­
tegers, right-aligned in their field. The sign of the
product is determined by the rules of algebra from the multiplier and multiplicand signs, even if one or
both operands are zero.
The multiplier and product fields may overlap when
their low-order bytes coincide.
Condition Code: The code remains unchanged.
Program Inte1'ruptions:
Operation (if decimal feature is not installed)
Addressing
Protection
Specification
Data
Programming Note
When the multiplicand does not have the desired
number of leading zeros, multiplication may be pre­
ceded by a ZERO AND ADD into a larger field.
Divide Decimal DP 55 FD
7 8 11 12 1516
The dividend (the first operand) is divided by the
divisor (the second operand) and replaced by the
quotient and remainder.
The quotient field is placed leftmost in the first op­
erand field. The remainder field is placed rightmost in
the first operand field and has a size equal to the di­
visor size. Together, the quotient and remainder oc­
cupy the entire dividend field; therefore, the address
of the quotient field is the address of the first oper­
and. The size of the quotient field in eight-bit bytes
is Ll -L2, and the length code for this field is one
less (Ll -L2 -1). When the divisor length code
is larger than seven (15 digits and sign) or larger
than or equal to the dividend length code, a specifi­
cation exception is recognized. The operation is sup­
pressed, and a program interruption occurs.
The dividend, divisor, quotient, and remainder are
all signed integers, right-aligned in their fields. The
sign of the quotient is determined by the rules of al­
gebra from dividend and divisor signs. The sign of the
remainder has the same value as the dividend sign.
These rules are true even when quotient or remainder
is zero.
Decimal Arithmetic 37
Previous Page Next Page