digits, from one to 31, and the sign;
this corresponds to an operand length of
one to 16 bytes.
A decimal zero normally has a plus sign, but multiplication, division, and over­
flow may produce a zero value with a
minus sign. Such a negative zero is a
valid operand and is treated as equal to
a positive zero by COMPARE DECIMAL.
The lengths of the two operands speci­
fied in the instruction need not be the
same. If necessary, the shorter operand
is considered to be extended with zeros
on the left. Results, however, cannot
exceed the first-operand length as spec­
ified in the instruction.
When a carry or leftmost nonzero digits
of the result are lost because the
first-operand field is too short, the
result is obtained by ignoring the over­
flow digits, condition code 3 is set,
and, if the decimal-overflow mask bit is
one, a program interruption for decimal
overflow occurs. The operand lengths
alone are not an indication of overflow;
nonzero digits must have been lost
during the operation.
The operands of decimal-arithmetic
instructions should not overlap at all
or should have coincident rightmost
bytes. In ZERO AND ADD, the operands
may also overlap in such a manner that
the rightmost byte of the first operand
(which becomes the result) is to the
right of the rightmost byte of the
second operand. For these cases of
proper overlap, the result is obtained
as if operands were processed right to
left. Because the codes for digits and
signs are verified during the perform­
ance of the arithmetic, improperly
overlapping operands are recognized as
data exceptions.
Programming Note
A packed decimal number in storage may
be designated as both the first and
second operand of ADD DECIMAL, COMPARE DECIMAL, DIVIDE DECIMAL, MULTIPLY DECI­ MAL, SUBTRACT DECIMAL, or ZERO AND ADD.
Thus, a decimal number may be added to
itself, compared with itself, and so
forth; SUBTRACT DECIMAL may be used to
set a decimal field in storage to zero,
and, for MULTIPLY DECIMAL, a decimal
number may be squared in place.
EDITING INSTRUCTIONS The editing instructions are EDIT and
EDIT AND MARK. For these instructions,
only the first operand (the pattern) has
an explicitly specified length. The
second operand (the source) is consid­
ered to have as many digits as necessary
for the completion of the operation.
Overlapping
instructions
suIts.
operands
yield
for the editing
unpredictable re- EXECUTION OF DECIMAL INSTRUCTIONS During the execution of a decimal
instruction, all bytes of the operands
are not necessarily accessed concurrent­
ly, and the fetch and store accesses to
a single location do not necessarily
occur one immediately after the other.
Furthermore, for decimal instructions,
data in source fields may be accessed
more than once, and intermediate values
may be placed in the result field that
may differ from the original operand and
final result values. (See the section
"Storage-Operand Consistency" in Chapter 5, "Program Execution.") Thus, in a
multiprocessing configuration, an
instruction such as ADD DECIMAL cannot
be safely used to update a shared stor­
age location when the possibility exists
that another CPU may also be updating
that location.
OTHER INSTRUCTIONS FOR DECIMAL OPERANDS In addition to the decimal instructions
in this chapter, MOVE NUMERICS and MOVE ZONES are provided for operating on data
of lengths up to 256 bytes in the zoned
format. Two instructions are provided
for converting data between the zoned
and packed formats: PACK transforms
zoned data of lengths up to 16 bytes
into packed data, and UNPACK performs
the reverse transformation. MOVE WITH OFFSET can operate on packed data of
lengths up to 16 bytes. Two
instructions are provided for conversion
between the packed-decimal and signed­
binary-integer formats. CONVERT TO BINARY converts packed decimal to
binary, and CONVERT TO DECIMAL converts
binary to packed decimal; the length of
the packed decimal operand of these
instructions is eight bytes (15 digits
and sign). These seven instructions are
not considered to be decimal
instructions and are described in Chap­ ter 7, "General Instructions." The
editing instructions in this chapter may
also be used to change data from the
packed to the zoned format. INSTRUCTIONS The decimal instructions and their
mnemonics, formats, and operation codes Chapter 8. Decimal Instructions 8-3
are listed in the figure "Summary of
Decimal Instructions." The figure also
indicates when the condition code is set
and the exceptional conditions in oper­
and designations, data, or results that
cause a program interruption.
Note: In the detailed descriptions of
the individual instructions, the mnemon-
Mne-
Name monic
ADD DECIMAL AP SS COMPARE DECIMAL CP SS DIVIDE DECIMAL DP SS EDIT ED SS EDIT AND MARK EDMK SS, MULTIPLY DECIMAL MP SS SHIFT AND ROUND DECIMAL SRP SS SUBTRACT DECIMAL SP SS ZERO AND ADD ZAP SS EXElanation: C C C C C C C ic and the symbolic operand designation
for the assembler language are shown
with each instruction. For ADD DECIMAL, for example, AP is the mnemonic and DtCLt,Bt),D2Cl2,B2) the operand desig­
nation. Op Characteristics Code A D OF ST FA
A D F9
A SP D DK ST FD
A D ST DE
A D Gl R ST OF A SP D ST FC A D OF ST FO A D DF ST FB
A D DF ST Fa A Access exceptions for logical addresses. C Condition code i s set.
D Data exception.
DF Decimal-overflow exception.
DK Decimal-divide exception.
Gl Instruction execution includes the implied use of general register 1.
R PER general-register-alteration event. SP Specification exception. SS SS instruction format.
ST PER storage-alteration event.
Summary of Decimal Instructions
8-4 System/370 Principles of Operation
Previous Page Next Page