Search code examples
assemblyendiannesspowerpc

PPC clrlwi command - is the value digit included in the mask?


I'm reading some code in PPC 750 Big-endian and not clear on the clear statement.

clrlwi.   r12, r12, 28

Is it: Clear to the Left of bit 28 (leaving 28,29,30,31) -or- Clear Left including bit 28 (leaving 29,30,31)?

I've read the PPC docs I have, did my best with Google search but can't find anything that makes this... "clear" to me. (bad pun, I know.)


Solution

  • The instruction is a simplified form of rlwinm, which generates a mask from MB to ME, inclusive. MB in this case is 28 and ME is always 31 for clrlwi, so the mask will contain bits from 28 to 31, inclusive.

    This is logical. If the bit selected wasn't included you could never select the full range from 0 to 31 and would always be masking away at least one bit from the result.

    More information about the masks can be found from IBM.