Data Format. . Zoned Format
Packed Format
Number Representation
Instructions .
ADD DECIMAL. .
COMPARE DECIMAL DIVIDE DECIMAL. EDIT .... EDIT AND MARK. . MULTIPLY DECIMAL. Contents SHIFT AND ROUND DECIMAL. SUBTRACT DECIMAL ZERO AND ADD .
Decimal instructions provide arithmetic, shifting, and
editing operations on decimal data. These instruc­
tions constitute the decimal feature.
Data Format
Decimal operands reside in main storage and may be
in either the zoned or packed format.
Zoned Format
In the zoned format, the rightmost four bits of a
byte are called the numeric (N) and normally com­
prise a code representing a decimal digit. The left­
most four bits of a byte are called the zone (Z), ex­
cept for the rightmost byte of the field, where these
bits may be treated either as a zone or as a sign (S) code.
Packed Format I DID 1 DID 1 DID 1 Dis
In the packed format, each byte contains two deci­
mal digits (D), except for the rightmost byte, which
contains a sign to the right of a decimal digit. The
digit and sign codes each comprise four bits.
Arithmetic and shifting are performed with oper­
ands in the packed format and generate results in
the packed format. Decimal numbers in the zoned,
format are represented as part of an alphameric char­
acter set, which includes also alphabetic and special
Decimal Instructions
147
147
147
148
148
149
149
149 150 152
153
153
154
155
characters. The zoned format is usually produced by
source-document input devices, such as a card read­
er, and is usually used for printing decimal data on
an output device.
The instructions MOVE ZONES and MOVE NUMERICS are provided for operating on data in
the zoned format. Two instructions are provided for
converting data between the zoned and packed for­
mats: the PACK instruction transforms zoned data
into packed data, and UNPACK performs the re­ verse transformation. These four instructions are not
part of the decimal feature and are described in the
chapter" General Instructions." The instructions
EDIT and EDIT AND MARK may also be used to
change data from the packed to the zoned format.
Decimal operands occupy fields in main storage
that start on a byte boundary. For all decimal in­
structions other than EDIT and EDIT AND MARK,
the operands are in the packed format and are com­
posed of one to sixteen 8-bit bytes. For the two edit­
ing instructions, operands of up to 256 bytes in
length can be designated.
F or the decimal arithmetic instructions, the
lengths of the two operands specified in the instruc­
tion need not be the same. If necessary, the oper­
ands are considered to be extended with zeros to
the left of the high-order digit. Results, however,
never exceed the first-operand field size as specified
in the instruction. When a carry or high-order signif­
icant digits are lost because the first-operand field is
too small, a program interruption for decimal over­
flow occurs, provided the decimal-overflow mask bit
is one. For the two editing instructions, only one
operand (the pattern) has an explicitly specified
length; the other operand (the source) is considered
Decimal Instructions 147
to have as many digits as necessary for the comple­
tion of the operation.
The operand fields in decimal instructions, other
than EDIT and EDIT AND MARK, should not ov­
erlap at all or should have coincident rightmost
bytes. In ZERO AND ADD, the field may also over­
lap in such a manner that the rightmost byte of the
first operand is to the right of the rightmost byte of
the second operand. For these cases of proper over­
lap, the result is obtained as if operands were pro­
cessed right to left. Because the code configurations
for digits and signs are verified during the perform­
ance of the arithmetic, improperly overlapping fields
are recognized as data exceptions. In editing, over­
lapping operands yield unpredictable results.
During the execution of a decimal instruction, all
bytes of the operands are not necessarily accessed
concurrently, and the fetch and store accesses to a
single location do not necessarily occur one immedi­
ately after the other. Furthermore, for decimal in­
structions, intermediate values may be placed in the
result field that may differ from the original operand
and final result values. Thus, an instruction such as
ADD DECIMAL cannot be safely used to update a
shared location in main storage when the possibility
exists that another CPU may also be updating that
location.
Number Representation Packed dedmal numbers are represented as right­
aligned true integers with a plus or minus sign.
The digits 0-9 have the binary encoding 0000- 1 001. The codes 1010-1111 are invalid as digit
Name Mnemonic
ADD DECIMAL AP S5 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 Explanation: A Access exceptions
C
Condition code is set
o Data Elxception OF Decimal-overflow exception OK Decimal-divide exception
Decimal Instruction Summary
148 System/370 Principles of Operation C
C
C
C
C
C
C
codes and are interpreted as sign codes, with 1010, 1100, 1110, and 1111 recognized as plus and with 1011 and 1101 recognized as minus. The codes 0000-1001 are invalid as sign codes. A data excep­
tion is recognized when an invalid code is detected.
The operation is terminated, except when the sign
position contains an invalid sign code, in which case
the operation is suppressed.
Although alternate encoding of the sign in an
operand is accepted, the preferred sign codes are
always generated for the results of decimal arithme­
tic and shifting operations (for the first-operand field
of ADD DECIMAL, DIVIDE DECIMAL, MULTI­ PLY DECIMAL, SHIFT AND ROUND DECI­
MAL, SUBTRACT DECIMAL, and ZERO AND
ADD). These codes are plus, 1100, and minus, 1101. They are provided even when the operand
value is otherwise unchanged, such as when adding
zero to a number or when shifting the field by a zero
amount. The editing instruction, as well as UN­ PACK, generates the zone code 1111.
Instructions
The decimal instructions and their mnemonics, for­
mats, and operation codes are listed in the following
table. The table also indicates when the condition
code is set and the exceptions in operand designa­
tions, data, or results that cause a program interrup­
tion. Note: In the detailed descriptions of the individual
instructions, the mnemonic and the symbolic oper­
and designation for the IBM System/370 assembly
language are shown with each instruction. For ADD
DECIMAL, for example, AP is the mnemonic and
Characteristics Code PO A 0 OF ST FA PO A 0 F9 PO A SP 0 OK ST FD PO A 0 ST DE PO A 0 R ST OF PO A SP 0 ST FC PO A 0 OF ST FO PO A 0 OF ST FB PO A 0 OF ST Fa PO Decimal feature
R
PER general register alteration event SP Specification exception SS SS instruction format ST PER storage alteration event
Previous Page Next Page