vcntmbb

Vector Count Mask Bits Byte

vcntmbb RT,VRB,MP

Counts the number of true (or false) mask bits in a VSR and places the count in the leftmost byte of a GPR.

Details

The Vector Count Mask Bits Byte instruction counts the number of byte elements having bit 0 set to the value MP in VSR[VRB+32] and places the count into bits 0:7 of GPR[RT]. Bits 8:63 of GPR[RT] are set to 0.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
count = 0
do i = 0 to 15
    count ←count + EXTZ8(VSR[VRB+32].byte[i].bit[0]=MP)
end
GPR[RT] ←count << 56

Programming Note

This instruction is useful for counting the number of bytes in a vector register where the least significant bit matches a specified mask value (MP). Ensure that the Vector Facility is enabled by checking and setting the VEC bit in the Machine State Register (MSR) before using this instruction. The result is left-shifted 56 bits, so only the lower byte of GPR[RT] contains the count. This instruction operates at the problem state privilege level.

Example

vcntmbb r3, v3, 0

Encoding

Binary Layout
0
0
RT
6
MP
11
VRB
15
1602
16
 
Format VX-form
Opcode 0x10180642
Extension VMX (AltiVec)
Registers Altered None

Operands

  • RT
    Target General Purpose Register
  • VRB
    Source Vector Register
  • MP
    Mask Bit (0 or 1)