Exclusive Or; Shiftingandrotating Bits; Shifting Bits - HP -16C Owner's Handbook Manual

Table of Contents

Advertisement

46
Section 4: Arithmetic and Bit Manipulation Functions
EXCLUSIVE OR
The
function (the logical difference) compares the corre-
sponding bits in two words and yields a 1 only if two corresponding
bits are different.
Example: Use the
function to determine if two binary
quantities (01010101, and 01011101,) are the same. A 1 in the result
signifies that the two quantities are different at those bit
position(s).
Keystrokes
Display
([STATUS]: 2-16-0000)
1010101 [ENTER]
1010101 b
1011101
1011101
b
1000 b
The two numbers differ
in the fourth bit from the
right.
Shifting and Rotating Bits
Shifting and rotating operations cause the bits of a word to be
moved left or right. The fate of the bit moved off the end of the
word, and the value of the bit entering the vacated position, depend
upon the type of shift or rotate performed.
Flag 4 (carry) is set or cleared by any shift or rotate function,
except
(left-justify), as shown in the diagrams below.
Shifting Bits
The HP-16C can perform two types of shifts on the contents of the
X-register: a logical shift or an arithmetic shift. The latter
preserves the sign bit. The HP-16C can also left-justify the contents
of the X-register.
Logical Shifts. Pressing
(shift left) or
(shift right)
moves all the bits of the word in the X-register one bit to the left or
right. Bits shifted out of the word are shifted into the carry bit, and
the previous state of the carry bit is lost. The new bits generated at
the opposite end of the word are always zeros.
I:l<—— |=
o|«—0
Carry
X-Register
0O—>|e
> ——-—»l__—]
C

Advertisement

Table of Contents
loading

Table of Contents