The significance starter forces the significance indicator to
the on state and hence causes the decimal point to be pre­
served. Because the minus-sign code has no effect on the
significance indicator, the CR symbol is also preserved.
Edit and Mark (EDMK)
After an EDIT AND MARK operation, a symbol (such as a
dollar sign) can be inserted at the appropriate position in the
edited result. Usually a currency symbol is inserted to the
immediate left of the first significant digit in the amount;
however, if a decimal point appears in an amount less than
one, the currency symbol must be inserted to the immediate
left of the decimal point. A typical operation would leave no
blank between the currency symbol and the amount, thus
protecting against one form of alteration when the result is
printed on a check.
If significance is not forced by the significance starter, the
EDIT AND MARK operation inserts into general register 1
an address one more than the address at which a currency
symbol would normally be inserted. After one is subtracted
from the value in general register 1 (for example, by using a BRANCH ON COUNT instruction with R 1 set to one and
R2 set to zero), a MOVE instruction (MV!) may be used to
position the symbol in main storage.
Machine Format Op Code
92 5B I 000 Assembler Format Op Code 01 (B1), 12 MVI O(1),C'$'
If significance is forced, general register 1 remains un­
changed. Therefore, the address of the character following
the Significance starter should be placed in the register be­
fore the EDIT AND MARK instruction is performed. Multiply Decimal (MP)
Assume that the signed, packed-decimal field in storage lo­
cations 1202-1204 (the multiplicand) is to be multiplied by
the signed, packed-decimal field in locations 500-501 (the
multiplier). 1202 1204 Multiplicand 138 146 I 00 I 500 501 Multiplier Because there is a total of eight significant digits in the
multiplier and multiplicand, a field at least five bytes in
length must be reserved for the signed result. As indicated in
the programming note for MULTIPLY DECIMAL, a ZERO AND ADD into a larger field can provide the required space.
If it is assumed
Register 4 contains 00 00 12 00 Register 6 contains 00 00 05 00 then execution of the assembler instruction ZAP X'100'(5,4),2(3,4)
sets up a new multiplicand in storage locations 1300-1304 as follows. 1300 1304 Multiplicand (new) I 00 I 00 I 38 1 46 1 00 I Now, after the instruction
Machine Format Op Code L1 L2 B1
FC I 4 11 I 4 100 6 000 Assembler Format Op Code 01 (L
1
, B
1
), 02 (L2' B
2
) MP X'1 00'(5,4) ,0(2,6)
is executed, storage locations 1300-1304 contain the prod­
uct 01 2345 66 OC. Shift and Round Decimal (SRP) The SRP instruction can be used for shifting decimal fields
in main storage. When the field is shifted right, rounding can
also be done.
Decimal Left Shift
In this example, the contents of storage location FIELD 1
are shifted three places to the left, effectively multiplying
the contents of FIELD 1 by 1000. FIELD! is six bytes long,
and its contents are shown in "FIELDI (before)" below.
The following SRP instruction performs the above operation:
Machine Format Op Code
L1 13 S1 B2
°2 FO 5 I 0 **** 0 003 Assembler Format Op Code S1 S2' 13 SRP FIELOH6),3,0 Appendix I. Number Representation and Instruction-Use Examples 307
FIELD1 (before): 00 01 23 45 67 8C
FIELD1 (after): 12 34 56 78 00 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 by 10 and discarding the remainder.
FIELD2 is five bytes in length. The following SRP instruc­ tion performs this operation:
Machine Format Ll 13 Sl 8
2 02 r---
F
-
O
"---":"-4 ""-:;1 1-2 Op Code
Assembler Format SRP 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
(one place)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 be rep­ resented as 64 -n. In this example, a right shift of one is
represented as 64 --I.
Decimal Right Shift and Round
In this example, the contents of storage location FIELD3
are shifted three places to the right and rounded, effectively
dividing by 1,000 and rounding to the nearest whole num­ ber. FIELD3 is four bytes in length.
Machine Format OpCode Ll 13 Sl 8
2 02 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 Format Op Code 51 (L
1
), S2' 13 SRP FIEL03(4),64 -3,5
FIELD3 (before): 12 39 60 OC FIELD3 (after): 00 01 24 OC The shift amount (three places) is specified in the D2 field.
The 13 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 of 10 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
by 10 raised to the power specified by the shift value.
In this example, the SRP 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 a fixed­ 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 the vari­ able power of 10 contained in register 3:
Machine Format Op 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 1 = 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 x 10
3
= 127 000 FIELD4 (after): 01 27 00 00 OC The implied decimal point is now shifted two places
to the left.
Previous Page Next Page