vcntmbw

Vector Count Mask Bits Word

vcntmbw RT,VRB,MP

Counts the number of word elements in a vector register that have bit 0 set to a specified value.

Details

The vcntmbw instruction counts the number of word elements in VSR[VRB+32] that have bit 0 set to the value specified by MP. The count is then placed into bits 0:5 of GPR[RT], with bits 6:63 of GPR[RT] being set to 0.

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()
count = 0
do i = 0 to 3
    count ←count + EXTZ64(VSR[VRB+32].word[i].bit[0]=MP)
end
GPR[RT] ←count << 58

Programming Note

The vcntmbw instruction is useful for counting the number of word elements in a vector register that have their least significant bit set to a specified value. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, it will raise an exception. The result is stored in the upper bits of the target GPR, so be cautious when interpreting the output.

Example

vcntmbw r3, v3, 0

Encoding

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

Operands

  • RT
    Target General Purpose Register
  • VRB
    Source Vector Register
  • MP
    Mask Bit Value