Shift Value Amount and Direction 011111 31 digits to the left 000001 One digit to the left 000000 No shift
111111 One digit to the right 100000 32 digits to the right
For a right shift, the 13 field, bits
12-15 of the instruction, are used as a
decimal rounding digit. The first oper­
and, which is treated as positive by
ignoring the sign, is rounded by deci­
mally adding the rounding digit to the
leftmost of the digits to be shifted out
and by propagating the carry, if any, to
the left. The result of this addition
is then shifted right. Except for
validity checking and the participation
in rounding, the digits shifted out of
the rightmost decimal-digit position are
ignored and are lost.
If one or more nonzero digits are shift­
ed out during a left shift, decimal
overflow occurs. The operation is
completed. The result is obtained by
ignoring the overflow digits, and condi­
tion code 3 is set. If the decimal­
overflow mask is one, a program
interruption for decimal overflow
occurs. Overflow cannot occur for a
right shift, with or without rounding,
or when no shifting is specified.
In the absence of overflow, the sign of
a zero result is made positive. If
overflow occurs, the sign of the result
is the same as the original sign but
with the preferred sign code.
A data exception is recognized when the
first operand does not have valid sign
and digit codes or when the rounding
digit is not a valid digit code. The
validity of the first-operand codes is
checked even when no shift is specified,
and the validity of the rounding digit
is checked even when no addition for
rounding takes place.
Resulting Condition Code:
o
1
Result zero; no overflow
Result less than zero; no
flow
over-
2
3
Result greater than zero; no
overflow Overflow Program Exceptions:
Access (fetch and store, operand 1)
Data
Decimal overflow
Programming Notes 1. Examples of the use of the SHIFT AND ROUND instruction are given in
Appendix A.
2. SHIFT 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 decimal number
even with rounding.
3. For right shifts, the rounding
digit 5 provides conventional
rounding of the result. The round­
ing digit a specifies truncation
without rounding.
4. When the B2 field is zero, the
six-bit shift value is obtained
directly from bits 42-47 of the
instruction.
SUBTRACT DECIMAL
[55]
'FB' I s, a 8 12 16 20 32 36 47
The second operand is subtracted from
the first operand, and the resulting
difference is placed at the first­
operand location. The operands and
result are in the packed format.
SUBTRACT DECIMAL is executed the same as
ADD DECIMAL, except that the second
operand is considered to have a sign
opposite to the sign in storage. The
second operand in storage remains
unchanged.
Resulting Condition Code: a 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
Chapter 8. Decimal Instructions 8-11
ZERO AND ADD
[55] F8 I l. I l, lB. I B, o 8 12 16 20 32 36 47
The second operand is placed at the
first-operand location. The operation
is equivalent to an addition to zero.
The operand and result are in the packed
format. Only the second operand is checked for
valid sign and digit codes. Extra zeros
are supplied on the left for the shorter
operand if needed.
If the first operand is too short to
contain all leftmost nonzero digits of
the second operand, decimal overflow
occurs. The operation is completed.
The result is obtained by ignoring the
overflow digits, and condition code 3 is
set. If the decimal-overflow mask is
one, a program interruption for decimal
overflow occurs.
In the absence of overflow, the sign of
a zero result is made positive. If
overflow occurs, a zero result is given
8-12 5ystem/370 Principles of Operation
the sign of the second operand but with
the preferred sign code.
The two operands may overlap, provided
the rightmost byte of the first operand
is coincident with or to the right of
the rightmost byte of the second
operand. In this case the result is
obtained as if the operands were proc­
essed right to left.
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; store,
operand 1)
Data
Decimal overflow
Programming Note
An example of the use of the ZERO AND ADD instruction is given in Appendix A.
Previous Page Next Page