One rlwinm does the shift and the mask
In C, prying a packed field loose reads as two steps. Shift it down to bit 0, then mask off the neighbours that tagged along. PowerPC won't spend two instructions on that. rlwinm rotates and masks together, and MWCC leans on it every chance it gets.
Suppose the field you want is the 4-bit nibble at bits 8-11, one notch up from the bottom nibble.
rlwinm r3,r3,24,28,31
blr
Start with the 24. A left rotate by 24 is just a right rotate by 8 wearing a different hat, and it drops bits 8-11 squarely onto bits 0-3. Don't trust me, trace a value. 0x00000F00 rotated left by 24 comes out 0x0000000F. Anything still hanging around above the low 4 bits is wiped by that [28,31] mask.
There's your whole shift-and-AND in a single instruction. Memorise the shape and you'll spot it everywhere: rotate by r, mask [32-w, 31], and what you've really written is a right shift of r keeping the bottom w bits.
Now your target. The rotate amount hands you the right-shift count, the mask [MB,ME] hands you the width, and the C falls out of the two.
Your task
Write extract_nibble to reproduce the assembly above.