Decimal &i9h1 Shift
In this example, the contents of storage
location FIELD2 are shifted one place to
the right, effectively dividing the
contents of FIELD2 by10 and discarding
the remainder. FIELD2 is five bytes in
length. The following instruction
performs this operation:
Machine FormatOp Code FO 4
o1**** I Assembler Format
SRP FIELD2(5),64-1,000111111 I 6-bit two's
complement
for -1
FIELD 2 (before):01 23 45 67 8C
FIELD 2 (after):00 12 34 56 7C
In the SRP instruction, shifts to the
right are specified in the second
operand address by negative shift
values, which are represented as a
six-bit value in two's complement form.
The six-bit two's complement of a
number, n, can be specified as 64 -n.
In this example, a right shift of one is
represented as 64 -1.
Condition code 2 is set.
Decimal Right Shift and Round
In this example, the contents of storage
location FIELD3 are shifted three places
to the right and rounded, in effect
dividing by1000 and rounding up.
FIELD3 is four bytes in length.
Machine FormatOp Code FO 3
Assembler Format00111101 I 6-bit two's
complement
for -3
SRP FIELD3(4),64-3,5
FIELD 3 (before): 12 3960 OD FIELD 3 (after): 00 01 24 OD The shift amount (three places) is spec
ified in the D2 field. The13 field
specifies a rounding digit of 5. The
rounding digit is added to the last
digit shifted out (which is a 6), and
the carry is propagated to the left.
The sign is ignored during the addition.
Condition code 1 is set because the
result is less than zero.
Multiplyingg Variable Power of 1Q Since the shift value specified by the
SRP instruction specifies both the
direction and amount of the shift, the
operation is equivalent to multiplying
the decimal first operand by10 raised
to the power specified by the shift
value.
If the shift value is to be variable, it
may be specified by theB2 field instead
of the displacement D2 of the SRP
instruction. The general register
designated by B2 should contain the
shift value (power of10) as a signed
binary integer.
A fixed scale factor modifying the vari
able power of10 may be specified by
using both the B2 field (variable part
in a general register) and the D2 field
(fixed part in the displacement).
The SRP instruction uses only the right
most six bits of the effective address
D
2 (B
2
) and interprets them as a six-bit
signed binary integer to control the
left or right shift as in the preceding
shift examples.
Appendix A. NumberRepresentation and Instruction-Use Examples A-35
In this example, the contents of storage
location FIELD2 are shifted one place to
the right, effectively dividing the
contents of FIELD2 by
the remainder. FIELD2 is five bytes in
length. The following instruction
performs this operation:
Machine Format
o
SRP FIELD2(5),64-1,0
complement
for -1
FIELD 2 (before):
FIELD 2 (after):
In the SRP instruction, shifts to the
right are specified in the second
operand address by negative shift
values, which are represented as a
six-bit value in two's complement form.
The six-bit two's complement of a
number, n, can be specified as 64 -n.
In this example, a right shift of one is
represented as 64 -1.
Condition code 2 is set.
Decimal Right Shift and Round
In this example, the contents of storage
location FIELD3 are shifted three places
to the right and rounded, in effect
dividing by
FIELD3 is four bytes in length.
Machine Format
Assembler Format
complement
for -3
SRP FIELD3(4),64-3,5
FIELD 3 (before): 12 39
ified in the D2 field. The
specifies a rounding digit of 5. The
rounding digit is added to the last
digit shifted out (which is a 6), and
the carry is propagated to the left.
The sign is ignored during the addition.
Condition code 1 is set because the
result is less than zero.
Multiplying
SRP instruction specifies both the
direction and amount of the shift, the
operation is equivalent to multiplying
the decimal first operand by
to the power specified by the shift
value.
If the shift value is to be variable, it
may be specified by the
of the displacement D2 of the SRP
instruction. The general register
designated by B2 should contain the
shift value (power of
binary integer.
A fixed scale factor modifying the vari
able power of
using both the B2 field (variable part
in a general register) and the D2 field
(fixed part in the displacement).
The SRP instruction uses only the right
most six bits of the effective address
D
2 (B
2
) and interprets them as a six-bit
signed binary integer to control the
left or right shift as in the preceding
shift examples.
Appendix A. Number