FIELD1 (before): 00 01 23 45 67 8C
FIELD1 (after): 12 34 56 7800 OC The second-operand address in this instruction specifies the
shift amount (three places) completely in the D2 field. The
rounding factor, 13, is not used in left shift, but it must be a
valid decimal digit.
Decimal Right Shift
In this example, the contents of storage location lFIELD2
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 followingSRP instruc tion performs this operation:
MachineFormat Ll 13 Sl 8
202 r---
F
-
O "---":"-4 ""-:;1 1-2 Op Code
Assembler FormatSRP FIELD2(5),64 -1,0 FIELD2 (before): 01 23 45 67 8C
FIELD2 (after):00 12 34 56 7C 0011 1111 6-bit two's
complement
for -1
The second-operand address specifies the shift amount
(oneplace)l completely in the D2 field. In the SRI' instruc tion, shifts to the right are specified 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 berep resented as 64 -n. In this example, a right shift of one is
represented as 64 --I.
DecimalRight Shift and Round
In this example, the contents of storage location FIELD3
are shifted three places to the right and rounded, effectively
dividing by1,000 and rounding to the nearest whole num ber. FIELD3 is four bytes in length.
Machine FormatOpCode Ll 13 Sl 8
202 r----
F
- O """--3 --r-", -----T-5 -*-***--,---, I ClOG 1101 308 System/370 Principles of Operation Lr 6-bit two's
complement
for -:3
Assembler FormatOp Code 51 (L
1
),S2' 13 SRP FIEL03(4),64 -3,5
FIELD3 (before): 12 3960 OC FIELD3 (after): 00 01 24 OC The shift amount (three places) is specified in the D2 field.
The13 field specifies the rounding of 5. the rounding
factor is added to the last digit shifted out (which is a 6) and
the carry, if any, is propagated to the left. Since 5 + 6 in
decimal totals one, plus a carry, a carry is propagated in the
above example, and, as a result, 1239.6 becomes 1240.
Multiplying by a Variable Power of10 Since the shift value designated by the SRP instruction speci fies both the direction and amount of the shift, the operation
is equivalent to multiplying the decimal first-operand field
by10 raised to the power specified by the shift value.
In this example, theSRP instruction is used to adjust a
decimal field by a variable scale factor contained in a general
register. Main storage location FIELD4 contains a decimal
integer (the decimal point is implied to be on the right).
FIELD4 is five bytes in length. Register 3 contains afixed point binary value that is the scale factor of FIELD4 (the power of 10 by which FIELD4 is multiplied). The following
SRP instruction adjusts FIELD4 so that the implied decimal
point retains the two nearest decimal places (requiring the
implied decimal point to shift two places to the left, under
control of the D2 field)and multiplies FIELD4 by thevari able power of 10 contained in register 3:
Machine FormatOp Code FO 4 I 5 **** 002 Assembler Format Op Code Sl (Li), 02 (8
2
),13 SRP FI EL04(5),2(3),5
FIELD4 (before):00 00 00 12 7C Case 1: Register 3 contains 00 00 00 00 If the scale factor is zero, FIELD4 represents
1 27 x 10° = 127
FIELD4 (after):00 00 12 70 OC The implied decimal point is now shifted two places
to the left.Case 2: Register 3 contains 00 00 00 03 If the scale factor is 3, FIELD4 represents
127 x10
3 = 127 000 FIELD4 (after): 01 27 00 00 OC The implied decimal point is now shifted two places
to the left.
FIELD1 (after): 12 34 56 78
shift amount (three places) completely in the D2 field. The
rounding factor, 13, is not used in left shift, but it must be a
valid decimal digit.
Decimal Right Shift
In this example, the contents of storage location lFIELD2
are shifted one place to the right, effectively dividing the
contents of FIELD2 by
FIELD2 is five bytes in length. The following
Machine
2
F
-
O
Assembler Format
FIELD2 (after):
complement
for -1
The second-operand address specifies the shift amount
(one
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
represented as 64 --I.
Decimal
In this example, the contents of storage location FIELD3
are shifted three places to the right and rounded, effectively
dividing by
Machine Format
2
F
- O
complement
for -:3
Assembler Format
1
),
FIELD3 (before): 12 39
The
factor is added to the last digit shifted out (which is a 6) and
the carry, if any, is propagated to the left. Since 5 + 6 in
decimal totals one, plus a carry, a carry is propagated in the
above example, and, as a result, 1239.6 becomes 1240.
Multiplying by a Variable Power of
is equivalent to multiplying the decimal first-operand field
by
In this example, the
decimal field by a variable scale factor contained in a general
register. Main storage location FIELD4 contains a decimal
integer (the decimal point is implied to be on the right).
FIELD4 is five bytes in length. Register 3 contains a
SRP instruction adjusts FIELD4 so that the implied decimal
point retains the two nearest decimal places (requiring the
implied decimal point to shift two places to the left, under
control of the D2 field)and multiplies FIELD4 by the
Machine Format
2
),
FIELD4 (before):
1 27 x 1
FIELD4 (after):
to the left.
127 x
3
to the left.