Chapter 2. Programming Model
2-45
Instruction Set Summary
2.3.4.1.4 Integer Rotate and Shift Instructions
Rotation operations are performed on data from a GPR, and the result, or a portion of the
result, is returned to a GPR. See Appendix F, òSimplified Mnemonics,ó in
The
Programming Environments Manual
for a complete list of simpliTed mnemonics that
allows simpler coding of often-used functions such as clearing the leftmost or rightmost
bits of a register, left justifying or right justifying an arbitrary Teld, and simple rotates and
shifts.
Integer rotate instructions rotate the contents of a register. The result of the rotation is either
inserted into the target register under control of a mask (if a mask bit is 1 the associated bit
of the rotated data is placed into the target register, and if the mask bit is 0 the associated
bit in the target register is unchanged), or ANDed with a mask before being placed into the
target register.
The integer rotate instructions are summarized in Table 2-22.
Table 2-22. Integer Rotate Instructions
The integer shift instructions perform left and right shifts. Immediate-form logical
(unsigned) shift operations are obtained by specifying masks and shift values for certain
rotate instructions. SimpliTed mnemonics (shown in Appendix F, òSimplified
Mnemonics,ó in
The Programming Environments Manual
) are provided to make coding of
such shifts simpler and easier to understand.
Multiple-precision shifts can be programmed as shown in Appendix C, òMultiple-Precision
Shifts,ó in
The Programming Environments Manual
. The integer shift instructions are
summarized in Table 2-23.
Extend Sign Half Word
extsh
(
extsh.
)
r
A
,r
S
Count Leading Zeros
Word
cntlzw
(
cntlzw.
)
r
A
,r
S
Name
Mnemonic
Syntax
Rotate Left Word Immediate then AND with Mask
rlwinm
(
rlwinm.
)
r
A
,r
S
,
SH
,
MB
,
ME
Rotate Left Word then AND with Mask
rlwnm
(
rlwnm.
)
r
A
,r
S
,r
B
,
MB
,
ME
Rotate Left Word Immediate then Mask Insert
rlwimi
(
rlwimi.
)
r
A
,r
S
,
SH
,
MB
,
ME
Table 2-21. Integer Logical Instructions (Continued)
Name
Mnemonic
Syntax
Implementation Notes