PACKED
DECIMAL
NUMBERS
All decimal
arithmetic
instructions
operate
on
packed
decimal numbers,
each
consisting
of
from 1 to
31
decimal
digits
t
(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:
101O(X'A'),
1100(X'C'),
111O(X'E'),
or
1111 (X'F'). A
neg-
ative
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
(X'C')
for
positive results, and 1101 (X'D') for
negative
results. The
format
of
packed
decimal numbers is:
For
the
decimal
arithmetic
instructions, a
packed
decimal
number must
occupy
an
integral
number (l 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 form
described
above.
ZONED
DECIMAL
NUMBERS
In
zoned
decimal
format, a
single
decimal
digit
is
contained
_
••
!.LL!_
L'!L
____
'!L'!
____
..f
"7
_£
__
L
__
L
__
.
_I
I
-.I.
_
••.•
_
1'\
"")
,.
VVI'"I"
UII
t-'V:>IIIVII:>
~-I
v,
U ur"';,
UIIU
UII
PV:>IIIVII:>
v-v
v,
the byte
are
referred to as the
"zone"
of
the
decimal
digit.
A zoned deci
ma
I number consi sts
of
from 1 to
31
bytes,
with
the
decimal
sign
appearing
as
the
zone
for the last
byte,
as
follows:
The sign format is
EBCDIC
and
the
zones
are
1111.
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
reg-
isters 12 through 15
of
the
current
register
block
as the
t Except
EDIT
BYTE
STRING
(EBS),
which has
no
limit on
the
size
of numbers.
decimal
accumulator,
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
0),
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
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
II
L")
designate
the
length,
in bytes,
of
a
packed
decimal
number. (If L =
0,
a
length
of
16
bytes is assumed. )
ILLEGAL
DIGIT
AND
SIGN
DETECTION
Prior to
executing
any
decimal
instruction,
the basic
pro-
cessor
checks
a
II
deci
ma
I operands for the presence
of
illegal
decimal
digits
or
illegal
decimal
signs. For
all
dec-
imal
arithmetic
instructions, an
illegal
decimal
digit
is a
sign
code
(i.
e.,
in
the
range
X'A'
through
X'F')
that
ap-
pears anywhere
except
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
XIO
I
through X
'
9')
that
appears in the sign position
of
the
packed
decimal
number.
For the instructions DECIMAL MULTIPLY and DECIMAL
DIVIDE, the
illegal
sign and
digit
check
also includes a
check
for an
illegal
L field in the instruction.
Illegal
L fields
are
X'O' and
the
range
X'9'
to
XI
F'.
For the DECIMAL MULTIPLY
instruct~on,
only
registers
R14
and
R15
are
checked
for
illegal
digits.
The
original
con-
tents
of
R12
and
R13
are
ignored and
are
presumed to be
zeros.
If
an
illegal
digit
or
sign is
detected,
the
basic
processor
unconditionally
aborts the
execution
of
the instruction
(at
the time
that
the
illegal
digit
or
sign
is
detected),
sets
CC 1 to 1 and resets
CC2
to
O.
If
the
deci
ma
I ari thmeti c
fault
trap mask (bit position 10
of
the
program status words)
is
a
0,
the basic processor then
executes
the
next
instruc-
tion in
sequence;
however, if
the
decimal
arithmetic
fault
trap mask
is
a 1, the
basic
processor traps to
location
X'45'.
In
either
case,
the
contents
of
the
decimal
accumulator,
the
effective
decimal
operand,
CC3,
and
CC4
remain
unchanged.
Decimal Instructions
81