
RCPU
REFERENCE MANUAL
ADDRESSING MODES AND INSTRUCTION SET SUMMARY
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
4-15
The IU performs rotation operations on data from a GPR and returns the result, or
a portion of the result, to a GPR. Rotation operations rotate a 32-bit quantity left by
a specified number of bit positions. Bits that exit from position 0 enter at position
31. A rotate right operation can be accomplished by specifying a rotation of 32-
n
bits, where
n
is the right rotation amount.
Rotate and shift instructions use a mask generator. The mask is 32 bits long and
consists of 1-bits from a start bit,
MB
, through and including a stop bit,
ME
, and 0-
bits elsewhere. The values of
MB
and
ME
range from zero to 31. If
MB
>
ME
, the
1-bits wrap around from position 31 to position 0. Thus the mask is formed as fol-
lows:
if
MB
e
ME
then
mask[mstart:mstop]
= ones
mask[all other bits]
= zeros
else
mask[mstart:31] = ones
mask[0:mstop] = ones
mask[all other bits] = zeros
It is not possible to specify an all-zero mask. The use of the mask is described in
the following sections.
If condition register updating is enabled, rotate and shift instructions set condition
register field CR0 according to the contents of
r
A at the completion of the instruc-
tion. Rotate and shift instructions do not change the values of XER[OV] or XER[SO]
bits. Rotate and shift instructions, except algebraic right shifts, do not change the
XER[CA] bit.
Simplified mnemonics allow simpler coding of often-used functions such as clear-
Table 4-4 Rotate and Shift Operations
Operation
Description
Extract
Select a field of
n
bits starting at bit position
b
in the source register, right or left justify this field in the
target register, and clear all other bits of the target register to zero.
Insert
Select a left- or right-justified field of
n
bits in the source register, insert this field starting at bit position
b
of the target register, and leave other bits of the target register unchanged. (No simplified mnemonic
is provided for insertion of a left-justified field when operating on double-words; such an insertion
requires more than one instruction.)
Rotate
Rotate the contents of a register right or left
n
bits without masking.
Shift
Shift the contents of a register right or left
n
bits, clearing vacated bits to zero (logical shift).
Clear
Clear the leftmost or rightmost
n
bits of a register to zero.
Clear left
and shift
left
Clear the leftmost
b
bits of a register, then shift the register left by
n
bits. This operation can be used to
scale a known non-negative array index by the width of an element.
F
Freescale Semiconductor, Inc.
n
.