Divide Dec:imal (DP)
Assume that the signed, packed-decimal field at storagelo cations 2000-2004 (the dividend) is to be divided by the
signed, packed-decimal field at locations3000-3001 (the
divisor). Also assume:
Instruction address:005000 Location 5000 contains: FD 41 C 000 D 000 DP 0(5,12),0(2,13)
Register 12 contains00 00 20 00 Register 13 contains 00 00 30 00 Storage locations 2000-2004 contain 01 23 45 67 8C
Storage locations3000-3001 contain 32 1D
After the instruction at location5000 is executed, the
dividendfield is entirely replaced by the signed quotient
and remainder fields, as follows:2000 2004 Locations 2'000-2004 \ 38 \46 \ 00 \ 01 lac I Quotient I Remainder I Notes:
1. Because the signs of the dividend and divisor arediffer ent, the quotient receives a negative sign.
2. The remainder receives the sign of the dividend and the
length of the divisor.
3. If an attempt is made to divide the dividend by theone byte field at location 3001, the quotient will be too long
to fit within the four bytes allotted to it. Adecimal divide exception exists, causing a program interruption.
Edit (ED)
Because the decimal-feature instructions operate only on
packed-decimal data, it is necessary to convert the data to
the zoned format before a legible report can be printed.
Moreover, if the report is to be useful to a great manypeo ple, certain punctuation marks, such as commas and decimal
points, should be inserted in appropriate places. The highly
flexible EDIT instruction performs these two functions in a
single instruction execution.
This example shows step-by-step one way in which the
EDIT instruction can be used. The field to be edited (the
source) is four long; it is edited against a pattern 13
bytes long. ThefollOWing symbols are used: Svmbol b (Hexadecimal 40) ( (Hexadeci mal 21)
d(Hexadecimal 20) Meaning Blank character
Significance starter
Digitselector Assume that the source and pattern fields are: Source 1200 1203 306 System/370 Principles of Operation Pattern 1000 100C \40 120 120 16B 120 120 121 14B 120 1
20 \40 I C31 09
1 b d d d d ( d db C R
Execution of the instruction (assume that register 12con tains 00 00 10 00) Machine Format Op Code
DEOC 1 C 1 000 Assembler Format Op Code D1 (L, B
1
),O
2 (B
2
)
ED 0(13,12),X'200'(12)
alters the pattern field as follows:
Significance
Indicator
Pattern Digit Before/After Rule
b off/offleave(1 )
d0 off/off fill d 2 off/on(2) digit
on/onleave d 5 on/on digit
d 7 on/on digit
( 4 on/on digit
on/onleave d 2 on/on digit
d 6+ on/off(3) digit
b off/offfill C off/off fill R
off/offfill Notes: 200 Location 1000-100C bdd,dd( .ddbCR
bbd,dd( .ddbCR
bb2,dd( .ddbCR
same
bb2,5d(.ddbCR
bb2,57(.ddbCR
bb2,574.ddbCR
same
bb2,574.2dbCR
bb2,574.26bCR
same
bb2,574.26bbR
bb2,574.26bbb
(1) Thischaracter becomes the fill character.
(2) First nonzerodecimal source digit turns on significance
indicator.
(3)Plus sign in the four low-order bits of the byte turns
off significance indicator.
Thus, after the instruction is executed, the source isun changed, and the pattern is as follows:
Pattern1000 100C 140 140 1 F216B I F51 F71 F414B 1 F21 F6140 1
40 1
40 , b b 2 5 7 4 2 6 b b b Condition code = 2: result is greater than zero.
When printed, this new pattern field appears as:
2,574.26
If the number in the source field is changed to000002 6D,
a negative number, and the original pattern is used, the edited
result this time is:
Pattern1000 100C 1
40 1
40 1
40 1
40 1
40 1
40 1
40 14B 1 F2 I F6140 I ciEJ b b b b b b b 2 6 b C R Condition code = 1: result is less than zero.
Assume that the signed, packed-decimal field at storage
signed, packed-decimal field at locations
divisor). Also assume:
Instruction address:
Register 12 contains
Storage locations
After the instruction at location
dividend
and remainder fields, as follows:
1. Because the signs of the dividend and divisor are
2. The remainder receives the sign of the dividend and the
length of the divisor.
3. If an attempt is made to divide the dividend by the
to fit within the four bytes allotted to it. A
Edit (ED)
Because the decimal-feature instructions operate only on
packed-decimal data, it is necessary to convert the data to
the zoned format before a legible report can be printed.
Moreover, if the report is to be useful to a great many
points, should be inserted in appropriate places. The highly
flexible EDIT instruction performs these two functions in a
single instruction execution.
This example shows step-by-step one way in which the
EDIT instruction can be used. The field to be edited (the
source) is four
bytes long. The
d
Significance starter
Digit
20
1
Execution of the instruction (assume that register 12
DE
1
),
2
2
)
ED 0(13,12),X'200'(12)
alters the pattern field as follows:
Significance
Indicator
Pattern Digit Before/After Rule
b off/off
d
on/on
d 7 on/on digit
( 4 on/on digit
on/on
d 6+ on/off(3) digit
b off/off
off/off
bbd,dd( .ddbCR
bb2,dd( .ddbCR
same
bb2,5d(.ddbCR
bb2,57(.ddbCR
bb2,574.ddbCR
same
bb2,574.2dbCR
bb2,574.26bCR
same
bb2,574.26bbR
bb2,574.26bbb
(1) This
(2) First nonzero
indicator.
(3)
off significance indicator.
Thus, after the instruction is executed, the source is
Pattern
40
40
When printed, this new pattern field appears as:
2,574.26
If the number in the source field is changed to
a negative number, and the original pattern is used, the edited
result this time is:
Pattern
40
40
40
40
40
40
40