shifting to the left. Negative shift values, which are
represented in two's-complement notation, specify
shifting to the right. The following are examples of
the interpretation of shift values:
Shift ValUE! 011111 000001 000000 111111 100000 Amount and Direction
31 digits to the left One digit to the left No shift One digit to the right
32 digits to the right
The Lt, Bl, and Dt fields are interpreted in the
same manner as in the SS 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:
packed decimal 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 the h 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 the I 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 of the high-order digit positions during left shift,
a decimal overflow occurs and results in a program
interruption, provided that the decimal overflow I mask bit its one. Overflow cannot occur on right
shift or when no shifting is specified.
154 System/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
Program Exceptions: Operation (if the decimal feature is not installed)
Access (fetch and store, operand 1)
Data
Decimal overflow
Programming Note 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 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 SP 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
of SUBTRACT 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
Program Exceptions: Operation (if the decimal feature is not installed)
Access (fetch, operand 2; fetch and store, oper­
and 1)
Data
Decimal Overflow Programming Note
The operands of SUBTRACT DECIMAL may over­
lap 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 field.
Zero and Add
ZAP
[
o
The second operand is placed in the first-operand
location.
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 first-operand field is too short
to contain all significant digits of the second oper­
and, a decimal overflow occurs and results in a pro­
gram interruption, provided that the decimal over­
flow mask bit is one.
The first-operand and second-operand fields may
overlap :when the rightmost byte of the first-operand
field is coincident with or to the right of the right­
most byte of the second operand. In this case the
result is obtained as if the operands were processed
right to left.
Resulting Condition Code:
o Result is zero
1 Result is less than zero
2 Result is greater than zero
3 Overflow Program Exceptions: Operation (if the decimal feature is not installed)
Access (fetch, operand 2; store, operand 1)
Data
Decimal Overflow Decimal Instructions 155
Previous Page Next Page