than or eq[ual to the dividend length code, a specifi­
cation exception is recognized. The operation is sup­
pressed, and a program interruption occurs.
The dividend, divisor, quotient, and remainder are
all signed integers, right-aligned in their fields. The
sign of quotient is determined by the rules of
algebra from dividend and divisor signs. The sign of
the remainder has the same value as the dividend
sign. These rules are true even when the quotient or
remainder is zero. Overflow cannot occur. A quotient larger than the
number of digits allowed is recognized as a dedmal­
divide exception. The operation is suppressed, and a
program interruption occurs. The divisor and divi­
dend remain unchanged in their storage locations.
The divisor and dividend fields may overlap only
if their low-order bytes coincide.
Condition Code: The code remains unchanged.
Program Exceptions: Operation (if the decimal feature is not installed)
Access (fetch, operand 2; fetch and store, oper-
and 1) Specification Data
Decimal Divide
Programming Notes
The maximum dividend size is 31 digits and sign. Since the smallest remainder size is one digit and
sign, the maximum quotient size is 29 digits and sign.
The condition for a decimal divide exception can
be determined by a trial subtraction. The leftmost
digit of the divisor field is aligned with the leftmost­
less-one digit of the dividend field. When the divisor,
so aligned" is less than or equal to the dividend, a
divide exception is indicated.
A decimal-divide exception occurs if the dividend
does not have at least one leading zero.
Edit
ED [SS] _L -.1-.-
8
----'--(,
I 8 16 20 32 36 47 o
The format of the source (the second operand) is
changed from packed to zoned, and is modified un­
der control of the pattern (the first operand). The
edited result replaces the pattern.
Editing includes sign and punctuation control, and
the suppressing and protecting of leading zeros. It 150 System/370 Principles of Operation
also facilitates programmed blanking of all-zero
fields. Several fields may be edited in one operation,
and numeric information may be combined with
text.
The length field applies to the pattern (the first
operand). The pattern has the zoned format and may
contain any character. The source (the second oper­
and) has the packed format. The leftmost four bits
of a source byte must specify a decimal digit code (0000-1001); a sign code (1010-1111) is recognized
as a data exception and causes a program interrup­
tion. The rightmost four bits may specify either a
sign or a decimal digit.
The result is obtained as if both operands were
processed left to right one byte at a time. Overlap­ ping pattern and source fields give unpredictable
results.
During the editing process, each character of the
pattern is affected in one of three ways:
1. It is left unchanged.
2. It is replaced by a source digit expanded to
zoned format.
3. It is replaced by the first character in the pat­
tern, called the fill character.
Which of the three actions takes place is deter­
mined by one or more of the following: the type of
the pattern character, the state of the significance
indicator, and whether the source digit examined is
zero. Pattern Characters: There are four types of pattern
characters: digit selector, significance starter, field
separator, and message character. Their coding is as
follows:
Name
Digit selector Significance starter Field separator
Message character Code 0010 0000 0010 0001 0010 0010 Any other
The detection of either a digit selector or a signifi­
cance starter in the pattern causes an examination to
be made of the significance indicator and of a source
digit. As a result, either the expanded source digit or
the fill character, as appropriate, is selected to re­
place the pattern character. Additionally, encounter­
ing a digit selector or a significance starter may
cause the significance indicator to be changed.
The field separator identifies individual fields in a
multiple-field editing operation. It is always replaced
in the result by the fill character, and the significance
indicator is always off after the field separator is
encountered.
Message characters in the pattern are either re­
placed by the fill character or remain unchanged in
the result, depending on the state of the significance
indicator. They may thus be used for padding, punc­
tuation, or text in the significant portion of a field or
for the insertion of sign-dependent symbols.
Fill Character: The fill character is obtained from
the pattern as part of the editing operation. The first
character of the pattern is used as the fill character.
The fill character can have any code and may con­
currently specify a control function. If this character
is a digit selector or significance starter, the indicated
editing action is taken after the code has been as­
signed to the fill character.
Source Digits: Each time a digit selector or signifi­
cance starter is encountered in the pattern, a new
source digit is examined for placement in the pattern , field. The source digit either is given a zone and
replaces the pattern character or is disregarded.
The source digits are selected one byte at a time,
and a source byte is fetched for inspection only once
during an editing operation. Each source digit is ex­
amined only once for a zero value. The leftmost four
bits of each byte are examined first, and the right­
most four bits, when they represent a decimal-digit
code, remain available for the next pattern character
that calls for a digit examination. When the leftmost
four bits contain an invalid digit code, the operation
is terminated. At the time the left digit of a source
byte is examined, the rightmost four bits are checked
for the existence of a sign code. When a sign code is
encountered in the four rightmost bit positions, these
bits are not treated as a decimal-digit code, and a
new source byte is fetched from storage for the next
pattern character that calls for a source-digit exami­
nation.
When the source digit is stored in the result, its
code is expanded from the packed to the zoned for­
mat by attaching the zone code 1111.
Significance Indicator: The significance indicator,
by its on or off state, the significance or
nonsignificance, respectively, of subsequent source
digits or message characters. Significant source digits
replace their corresponding digit selectors or signifi­
cance starters in the result. Significant message char­
acters remain unchanged in the result.
The significance indicator, by its on or off state,
indicates also the negative or positive value, respec­
tively, of the source and is used as one factor in the
setting of the condition code.
The indicator is set to the off state, if not already
so set, at the start of the editing operation, after a
field separator is encountered, or after a source byte
is examined that has a plus code in the rightmost
four bit positions. Any of the codes 1010, 1100, 1110, and 1111 is considered a plus code.
The indicator is set to the on state, if not already
so set, when a significance starter is encountered
whose source digit is a valid decimal digit, or when a
digit selector is encountered whose source digit is a
nonzero decimal digit, and if in both instances the
source byte does not have a plus code in the right­
most four bit positions.
In all other situations, the indicator is not
changed. A minus sign code has no effect on the
significance indicator.
Result Characters: The field resulting from an edit­
ing operation replaces and is equal in length to the
pattern. It is composed from pattern characters, fill
characters, and zoned source digits.
If the pattern character is a message character and
the significance indicator is on, the message charac­
ter remains unchanged in the result. If the pattern
character is a field separator or if the significance
indicator is off when a message character is encoun­
tered in the pattern, the fill character replaces the
pattern character in the result.
If the digit selector or significance starter is en­
countered in the pattern with the significance indica­
tor off and the source digit zero, the source digit is
considered nonsignificant, and the fill character re­
places the pattern character. If a digit selector or
significance starter is encountered with either the
significance indicator on or with a nonzero decimal
source digit, the source digit is considered signifi­
cant, is zoned, and replaces the pattern character in
the result.
Result Condition: All digits examined are tested for
the code 0000. The sign of the last field edited and
whether all source digits in the field contain zeros
are recorded in the condition code at the completion
of the editing operation.
The condition code is made 0 when the last field
is zero, that is, when all source digits examined since
the last field separator are zeros. When the pattern
has no digit selectors or significance starters, the
source is not examined, and the condition code is
made O. Similarly, the condition code is made 0 when the last character in the pattern is a field sepa­
rator or when no digit selector or significance starter
is encountered beyond the last field separator.
When the last field edited is nonzero and the sig­
nificance indicator is on, the condition code is made
1 to indicate a result field less than zero.
Decimal Instructions 151
Previous Page Next Page