CP Programming
Fixed-Point Arithmetic
Fixed-point a d d i t i o n and s u b t r a c t i o n of 60-bit numbers a r e handled by the
long-add i n s t r u c t i o n s ( 3 6 and 37).
Negative numbers a r e represented i n o n e ' s
complement n o t a t i o n , and overflows a r e ignored.
The
s i g n b i t i s i n t h e
high-order b i t p o s i t i o n ( b i t
59),
and t h e binary p o i n t
i s
t o t h e r i g h t of t h e
low-order b i t p o s i t i o n ( b i t 0 ) .
The increment i n s t r u c t i o n s (50 through 77) handle fixed-point a d d i t i o n and
s u b t r a c t i o n of 18-bit numbers.
Negative numbers a r e represented i n one's
complement n o t a t i o n , and overflows a r e ignored.
The sign b i t
is
i n t h e
high-order b i t p o s i t i o n ( b i t 1 7 ) , and t h e binary point i s t o t h e r i g h t of the
low-order p o s i t i o n ( b i t 0 ) .
I n t e g e r m u l t i p l i c a t i o n i s handled as a subset operation of t h e
floating-multiply (42) i n s t r u c t i o n .
The i n t e g e r m u l t i p l y r e q u i r e s ' t h a t both
47-bit
i n t e g e r operands have zero exponents and a r e not normalized.
The r e s u l t
i s 48 b i t s with s i g n extension.
Normalized operands cause underflow r e s u l t s
to
be reported.
I f t h e r e s u l t s exceed 48 b i t s , overflow i s not d e t e c t e d .
A n i n t e g e r d i v i d e t a k e s s e v e r a l s t e p s .
For example, an i n t e g e r q u o t i e n t X 1
equal t o ~ 2 / ~ 3
i s produced by the following s t e p s .
I n s t r u c t i o n s
Remarks
Pack X 2 from X 2 and B O
Pack X 2
Pack X3 from X3 and
BO
Pack X3
Normalize X3 i n XO and BO
Normalize X3 ( d i v i s o r )
Normalize X 2 i n X 2 and BO
Normalize X2 (dividend)
F l o a t i n g q u o t i e n t of X 2 and XO t o X i
D i v i d e
Unpack X 1 t o X 1 and B 7
Unpack q u o t i e n t
S h i f t X 1 nominally l e f t B 7 places
S h i f t t o i n t e g e r p o s i t i o n
The d i v i d e r e q u i r e s t h a t both i n t e g e r (247 maximum) operands
must
be i n
floating-point format, and t h e dividend c o e f f i c i e n t must be l e s s than two
times t h e d i v i s o r c o e f f i c i e n t .
The normalize X3 i n s t r u c t i o n ensures t h i s
condition.
The normalize
X3
i n s t r u c t i o n l e f t - s h i f t s the d i v i s o r n p l a c e s (n)O), providing
a d i v i s o r exponent of negative n.
The q u o t i e n t exponent i s then
0
minus (-n)
minus 48 e q u a l s
n
minus
48<0.
After unpacking and l e f t - s h i f t i n g nominally, t h e negative ( o r zero) value i n
B7 r i g h t - s h i f t s the q u o t i e n t
48
minus n p l a c e s , producing an i n t e g e r quotient
i n X 1 .
A
remainder may be obtained by an i n t e g e r multiply of
X 1
and X 3 and
s u b t r a c t i n g the r e s u l t from X2.
Need help?
Do you have a question about the Cyber 170 State and is the answer not in the manual?
Questions and answers