Packed Decimal Numbers; Zoned Decimal Numbers; Decimal Accumulator; Decimal Instruction Format - Xerox Sigma 6 Reference Manual

Table of Contents

Advertisement

PACKED DECIMAL NUMBERS
All SIGMA 6 decimal arithmetic instructions operate on
packed decimal numbers, each consisting of from 1 to 31
decimal digits (in absolute form) plus a decimal sign. A
decimal digit is a 4-bit code in the range 0000 through 1001,
where 0000
=
0, 0001
=
1, 0010
=
2, 0011
=
3, 0100
=
4,
0101
=
5, 0110
=
6, 0111
=
7, 1000
=
8, and 1001
=
9.
A
positive decimal sign is a 4-bit code of the form:
1010(X'A'~
1100(X'C}, 1110(X ' E ' ), or 1111 (X'F"). A negative decimal
sign is a 4-bit code of the form: 1011 (X'B') or 1101 (X'D').
However, the decimal sign codes generated for the result of
a decimal instruction are: 1100 (XlC') for positive results,
and 1101 (X'D') for negative results.
The format of packed
decimal numbers is:
II
digit
I
sign
I
o
1
2
3
4
5
6
7
For the decimal arithmetic instructions, a packed decimal
number must occupy an integral number (1 through 16) of
consecutive bytes. Thus, a decimal number must contain an
odd number of decimal digits, the high-order digit (zero or
nonzero) of the number must be in bit positions 0-3 of the
first byte, the decimal sign must be in bit positions 4-7 of
the last byte, and all decimal digits and the decimal sign
must be 4-bit codes of the
fc-rm
described above.
ZONED DECIMAL NUMBERS
In zoned decimal format, a single decimal digit is contained
within bit positions 4-7 of a byte, and bit positions 0-3 of
the byte are referred to as the "zone" of the decimal digit.
A zoned decimal number consists of from 1 to 31 bytes, with
the decimal sign appearing as the zone for the last byte, as
follows:
A decimal number can be converted from zoned to packed
format by means of the instruction PACK DECIMAL DIGITS.
A decimal number can be converted from packed to zoned
format by means of the instruction UNPACK DECIMAL
DIGITS.
DECIMAL ACCUMULATOR
All decimal arithmetic instructions imply the use of registers
12 through 15 of the current register bank as the decimal ac-
cumulator, and registers 12 through 15 are treated as a single
16-byte register.
The entire decimal accumulator is used in
every decimal arithmetic instruction.
DECIMAL INSTRUCTION FORMAT
The general format of a decimal instruction is as follows:
The indirect address bit (position
a),
the operation code
(positions 1-7), the index field (12-14), and the reference
address field (15-31) all have the same functions for the
decimal instructions as they do for any other SIGMA 6 byte
addressing instruction.
However, bit positions 8-11 of the
instruction word do not refer to a general register; instead,
the contents of this field (designated by the character ilL")
designate the length, in bytes, of a packed decimal num-
ber.
(If
L
=
0, a length of 16 bytes is assumed.)
ILLEGAL DIGIT AND SIGN DETECTION
Prior to executing any decimal instruction, the computer
checks all decimal operands for the presence of illegal dec-
imal digits or illegal decimal signs.
For all decimal arith-
metic instructions except DECIMAL MULTIPLY and DECI-
MAL DIVIDE, an illegal decimal digit is a sign code (i. e.,
in the range X'A ' through X'F') that appears anywhere ex-
cept in bit positions 4-7 of the least significant byte (the
sign position) of the packed decimal number; an illegal
decimal sign is a digit code
(i.
e., in the range X'O' through
X ' 9
1
)
that appears in the sign position of the packed deci-
mal number.
For the instructions DECIMAL MULTIPLY and DECIMAL
DIVIDE, the effective decimal operand is checked for
illegal digits or signs as above.
However, the operand in
the decimal accumulator is checked to verify that there is
at least one legal decimal sign code somewhere in the num-
ber.
(This type of check is a result of the interruptibility
of these instructions, which may leave the decimal accumu-
latorwith a partially-completed result containing an internal
sign code.)
If
an illegal digit or sign is detected, the computer uncon-
ditionally aborts the execution of the instruction (at the
time that the illegal digit or sign is detected), sets CC 1 to 1
and -esets CC2 to O.
If the decimal arithmetic faul t trap
mask (bit position 10 of the program status doubleword)
is a 0, the computer then executes the next instruction in
sequence; however, if the decimal arithmetic fault trap
mask (PSDlO) is a 1, the computer traps to location X'4S'.
In either case, the contents of the decimal accumulator,
the effective deci mal operand, CC3, and CC4 remain
unchanged.
OVERfLOW DETECTION
Arithmetic overflow can occur during execution of the fol-
lowing decimal instructions:
DECIMAL ADD: overflow occurs when the sum of the two
decimal numbers exceeds the 31-digit ca)acity of the
decimal accumulator
(+
10 31 - 1 to - 10 3
+
1).
DECIMAL SUBTRACT: overflow occurs when the difference
between the two decimal numbers exceeds the 31-digit
capacity of the decimal accumulator.
Decimal Instructions
55

Advertisement

Table of Contents
loading

Table of Contents