andis.

AND Immediate Shifted

andis. RA, RS, UI

Performs a bitwise AND between a register and a 16-bit immediate shifted left by 16 bits. Always updates CR0.

Details

Performs a bitwise AND between RS and UI shifted left by 16 bits, storing the result in RA. The immediate operand is treated as unsigned and positioned in bits 16–31 of a 32-bit value with bits 0–15 cleared. Condition register CR0 is always updated regardless of the Rc bit (the dot indicates this behavior).

Pseudocode Operation

RA ← RS & (UI << 16)
CR0 ← (RA == 0, RA < 0, RA > 0, XER[SO])

Programming Note

The andis. instruction is useful for masking or clearing specific bits in a register by shifting an immediate value left by 5 bits before performing the AND operation. Be cautious with alignment as it affects performance; ensure that the immediate value does not exceed 31 to avoid unexpected results. This instruction operates at user privilege level and can generate exceptions if RA is an invalid register. The result of the operation sets CR0, which can be used for conditional branching.

Example

andis. r3, r4, 0x1234

// r3 = r4 & 0x12340000

Encoding

Binary Layout
29
0
RS
6
RA
11
UI
16
 
Format D-form
Opcode 0x74000000
Extension Base
Registers Altered CR0

Operands

  • RA
    Target Register
  • RS
    Source Register
  • UI
    Unsigned 16-bit Immediate