Shift  Value  Amount  and  Direction  011111   31  digits  to  the  left  000001   One   digit  to  the  left  000000   No   shift  
111111One   digit  to  the  right  100000   32  digits  to  the  right  
For a right shift, the13   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 isone,   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
Resultzero;   no  overflow  
Result less than zero; no
flow
over-
2
3
Result greater than zero; no
overflowOverflow   Program  Exceptions:  
Access (fetch and store, operand 1)
Data
Decimal overflow
ProgrammingNotes   1.  Examples  of  the  use  of  the  SHIFT  AND   ROUND   instruction  are  given  in  
Appendix A.
2. SHIFTAND   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 digita   specifies  truncation  
without rounding.
4. When the B2 field iszero,   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 operandis   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
3Overflow   Program  Exceptions:  
Access (fetch, operand 2; fetch and
store, operand 1)
Data
Decimal overflow
Chapter 8. Decimal Instructions 8-11
111111
For a right shift, the
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
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
Result less than zero; no
flow
over-
2
3
Result greater than zero; no
overflow
Access (fetch and store, operand 1)
Data
Decimal overflow
Programming
Appendix A.
2. SHIFT
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
without rounding.
4. When the B2 field is
six-bit shift value is obtained
directly from bits 42-47 of the
instruction.
SUBTRACT DECIMAL
[55]
'FB'
The second operand
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:
1 Result less than zero; no over-
flow
2 Result greater than zero; no
overflow
3
Access (fetch, operand 2; fetch and
store, operand 1)
Data
Decimal overflow
Chapter 8. Decimal Instructions 8-11
 
             
            












































































































































































































































































































































































































































































































































































