4. Rotate Left Word Immediate then AND with Mask M-form
rlwinm RA,RS,SH,MB,ME (Rc=0)
rlwinm. RA,RS,SH,MB,ME (Rc=1)
n <- SH
r <- ROTL32((RS)32:63, n)
m <- MASK(MB+32, ME+32)
RA <- r & m
The contents of register RS are rotated32 left SH bits. A mask is generated having 1-bits from bit MB+32 through bit ME+32 and 0-bits elsewhere. The rotated data are ANDed with the generated mask and the result is placed into register RA.
Special Registers Altered:
CR0 (if Rc=1)
Extended Mnemonics:
Examples of extended mnemonics for Rotate Left Word
Immediate then AND with Mask:
21 RS RA SH MB ME Rc
0 6 11 16 21 26 31
Extended: Equivalent to:
extlwi Rx,Ry,n,b rlwinm Rx,Ry,b,0,n-1
srwi Rx,Ry,n rlwinm Rx,Ry,32-n,n,31
clrrwi Rx,Ry,n rlwinm Rx,Ry,0,0,31-n
Programming Note:
This Instruction has many usages, the only one that I have verified so far is:
It can be used to shift the contents of the low-order 32 bits of a register right by n bits, by setting
SH=32-n, MB=n, and ME=31.
If just want the one bit (i1) after shifting, you can set SH=32-n, MB=31, and ME=31
Equivalence verified:
srwi Rx,Ry,n <=> rlwinm Rx,Ry,32-n,n,31
Example:
jtony@genoa:~/scrum/s8$ cat asm.c
#include <stdio.h>
#define rlwinm( output, input, sh, mb, me ) \
__asm__( "rlwinm %0, %1, %2, %3, %4" \
: "=r"(output) \
: "r"(input), "i"(sh), "i"(mb), "i"(me) \
: )
int main()
{
long x = 0x11223344556677A8L ;
long y ;
rlwinm( y, x, 27, 31, 31 ) ;
printf("0x%016lX -> 0x%016lX\n", x, y ) ;
return 0 ;
}
jtony@genoa:~/scrum/s8$ gcc asm.c ; ./a.out
0x11223344556677A8 -> 0x0000000000000001