shifting to the left. Negative shift values, which are
represented in two's-complement notation, specify
shiftingto the right. The following are examples of
the interpretation of shift values:
ShiftValUE! 011111 000001 000000 111111 100000 Amount and Direction
31 digits to theleft One digit to the left No shift One digit to the right
32 digits to the right
TheLt, Bl, and Dt fields are interpreted in the
same manner as in theSS format with two length
fields. The result replaces the first operand and is
not stored outside the field specified by the address
and length.
The first operand is considered to be in the:
packeddecimal format. Only its digit portion is shift the sign position does not participate in the shift
ing. Zeros are supplied for the vacated digit positions.
For right shift, the contents of theh field, bit
positions 12-15, are used as a rounding factor. The
first operand is rounded by decimally adding the
rounding factor to the leftmost digit to be shifted out
and by propagating the carry, if any, to the left. The
result of this addition is then shifted right. Both the
first operand and the rounding factor are considered
positive quantities for the purpose of this addition.
No overfllow results from the propagation of a carry
since all digits resulting from the addition participate
in the shift. Except for validity checking and the
participation in rounding, the digits shifted out of the
low-order digit position are ignored and are lost.
In the absence of overflow, the sign of a ze:ro
result is made positive. Otherwise, the sign of theI result is the same as the original sign, but the code is
the preferred sign code.
A data exception is recognized when the first
operand have valid sign and digit codes or
when the rounding factor does not have a valid digit
code.Th{! validity of first-operand codes is checked I even when no shift is specified, and the validity of
the roundling factor is checked even when no addi
tion for rounding takes place. The operation is termi
nated,exeept when the sign position contains an
invalid sign code, in which case the operation is sup
pressed.
When one or more significant digits are shifted
out ofthe high-order digit positions during left shift,
a decimal overflow occurs and results in a program
interruption, provided that the decimal overflowI mask bit its one. Overflow cannot occur on right
shift or when no shifting is specified.
154System/370 Principles of Operation Resulting Condition Code:
o Result is zero
1 Result is less than zero
2 Result is greater than zero
3 Overflow
ProgramExceptions: Operation (if the decimal feature is not installed)
Access (fetch and store, operand 1)
Data
Decimal overflow
Programming NoteSHIFT AND ROUND can be used for shifting up to
31 digit positions left and up to 32 digit positions
right. This is sufficient to clear all digits of any deci
mal field even when rounding in right shift is speci
fied.
Note that when the B2 field is zero, the six-bit
value, bits 26-31 of the second-operand address, is
obtained directly from bits 42-47 of the instruction.
Subtract DecimalSP Dl (Lt,Bl),D2(L2,B2) [SS] FB L1 L2 I B1 I I B2 I 0 8 12 16 20 32 36 47
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 the
signs and all digits of both operands. The execution
ofSUBTRACT DECIMAL is identical to that of
ADD DECIMAL, except that the sign of the second
operand, if negative, is treated as positive, and, if
positive, is treated as negative.
The sign of the difference is determined by the
rules of algebra. When the operation is completed
without an overflow, a zero difference has a positive
sign, but when high-order digits are lost because of
an overflow, a zero difference may be either positive
or negative, as determined by what the sign of the
correct difference would have been.
Resulting Condition Code:
o Difference is zero
1 Difference is less than zero
2 Difference is greater than zero
3 Overflow
represented in two's-complement notation, specify
shifting
the interpretation of shift values:
Shift
31 digits to the
32 digits to the right
The
same manner as in the
fields. The result replaces the first operand and is
not stored outside the field specified by the address
and length.
The first operand is considered to be in the:
packed
ing. Zeros are supplied for the vacated digit positions.
For right shift, the contents of the
positions 12-15, are used as a rounding factor. The
first operand is rounded by decimally adding the
rounding factor to the leftmost digit to be shifted out
and by propagating the carry, if any, to the left. The
result of this addition is then shifted right. Both the
first operand and the rounding factor are considered
positive quantities for the purpose of this addition.
No overfllow results from the propagation of a carry
since all digits resulting from the addition participate
in the shift. Except for validity checking and the
participation in rounding, the digits shifted out of the
low-order digit position are ignored and are lost.
In the absence of overflow, the sign of a ze:ro
result is made positive. Otherwise, the sign of the
the preferred sign code.
A data exception is recognized when the first
operand
when the rounding factor does not have a valid digit
code.
the roundling factor is checked even when no addi
tion for rounding takes place. The operation is termi
nated,
invalid sign code, in which case the operation is sup
pressed.
When one or more significant digits are shifted
out of
a decimal overflow occurs and results in a program
interruption, provided that the decimal overflow
shift or when no shifting is specified.
154
o Result is zero
1 Result is less than zero
2 Result is greater than zero
3 Overflow
Program
Access (fetch and store, operand 1)
Data
Decimal overflow
Programming Note
31 digit positions left and up to 32 digit positions
right. This is sufficient to clear all digits of any deci
mal field even when rounding in right shift is speci
fied.
Note that when the B2 field is zero, the six-bit
value, bits 26-31 of the second-operand address, is
obtained directly from bits 42-47 of the instruction.
Subtract Decimal
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 the
signs and all digits of both operands. The execution
of
ADD DECIMAL, except that the sign of the second
operand, if negative, is treated as positive, and, if
positive, is treated as negative.
The sign of the difference is determined by the
rules of algebra. When the operation is completed
without an overflow, a zero difference has a positive
sign, but when high-order digits are lost because of
an overflow, a zero difference may be either positive
or negative, as determined by what the sign of the
correct difference would have been.
Resulting Condition Code:
o Difference is zero
1 Difference is less than zero
2 Difference is greater than zero
3 Overflow