Programming Note
The moving and logical comparing instructions may
also be used in decimal calculations.
Add DecimalAP [SS] L---I F __ A --L-L1 --L--L2 --'---,IB1 I o 8 1 2 16 20 32 36 47
Thesecood operand is added to the first operand,
and the sum is placed in the first-operand location.
Addition is algebraic, taking into account the
signs and all digits of both operands. All sign and
digit codes 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 interruption is taken, provid
ed that the decimal-overflow 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
result, 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
indication of overflow.
The first-operand and second-operand fields may
overlap when their low-order bytes coincide; there
fore, it is possible to add a number to itself.
The sign of the sum is determined by the rules of
algebra. When the operation is completed without an
overflow, a zero sum has a positive sign, but when
high-order digits are lost because of an overflow, a
zero sum may be either positive or negative, as de
termined by what the sign of the correct sum would
have been.
Resulting Condition Code:
oSum is zero
1Sum is less than zero
2Sum is greater than zero
3 Overflow
Program Exceptions:
Operation (if the decimal feature is not installed)
Access (fetch, operand 2; fetch and store, oper
and 1)
Data
Decimal Overflow
Compare Decimal
The first operand is compared with the second, and
the condition code indicates the comparison result.
Comparison is algebraic, taking into account the
sign and all digits of both operands. All sign and
digit codes are checked for validity, and any valid
plus or minus sign is considered equal to any other
valid plus or minus sign, respectively. If the fields are
unequal in length, the shorter is extended with high
order zeros. A field with a zero value and positive
sign is considered equal to a field with a zero value
but negative sign. Neither operand is changed as a
result of the operation. Overflow cannot occur in
this operation.
The first-operand and second-operand fields may
overlap when their low-order bytes coincide. It is
possible, therefore, to compare a number with itself.
Resulting Condition Code:
o Operands equal
1 First operand is low
2 First operand is high
3 -
Program Exceptions:, Operation (if the decimal feature is not installed)
Access (fetch, operands 1 and 2)
Data
Divide DecimalDP I o
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
operand field. The remainder field is placed right
most in the first-operand field and has a size equal to
the divisor size. Together, the quotient and remain
der occupy the entire dividend field; therefore, the
address of the quotient field is the address of the
first operand. The size of the quotient field in eight
bit bytes is Lt-L2, and the length code for this field
is one less (L t -L2-1 ). When the divisor length code
is larger than seven (15 digits and sign) or larger
Decimal Instructions 149
The moving and logical comparing instructions may
also be used in decimal calculations.
Add Decimal
The
and the sum is placed in the first-operand location.
Addition is algebraic, taking into account the
signs and all digits of both operands. All sign and
digit codes 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 interruption is taken, provid
ed that the decimal-overflow 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
result, 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
indication of overflow.
The first-operand and second-operand fields may
overlap when their low-order bytes coincide; there
fore, it is possible to add a number to itself.
The sign of the sum is determined by the rules of
algebra. When the operation is completed without an
overflow, a zero sum has a positive sign, but when
high-order digits are lost because of an overflow, a
zero sum may be either positive or negative, as de
termined by what the sign of the correct sum would
have been.
Resulting Condition Code:
o
1
2
3 Overflow
Program Exceptions:
Operation (if the decimal feature is not installed)
Access (fetch, operand 2; fetch and store, oper
and 1)
Data
Decimal Overflow
Compare Decimal
The first operand is compared with the second, and
the condition code indicates the comparison result.
Comparison is algebraic, taking into account the
sign and all digits of both operands. All sign and
digit codes are checked for validity, and any valid
plus or minus sign is considered equal to any other
valid plus or minus sign, respectively. If the fields are
unequal in length, the shorter is extended with high
order zeros. A field with a zero value and positive
sign is considered equal to a field with a zero value
but negative sign. Neither operand is changed as a
result of the operation. Overflow cannot occur in
this operation.
The first-operand and second-operand fields may
overlap when their low-order bytes coincide. It is
possible, therefore, to compare a number with itself.
Resulting Condition Code:
o Operands equal
1 First operand is low
2 First operand is high
3 -
Program Exceptions:
Access (fetch, operands 1 and 2)
Data
Divide Decimal
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
operand field. The remainder field is placed right
most in the first-operand field and has a size equal to
the divisor size. Together, the quotient and remain
der occupy the entire dividend field; therefore, the
address of the quotient field is the address of the
first operand. The size of the quotient field in eight
bit bytes is Lt-L2, and the length code for this field
is one less (L t -L2-1 ). When the divisor length code
is larger than seven (15 digits and sign) or larger
Decimal Instructions 149