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.
Encoding
Binary Layout
0
0:5
RT
6:10
MP
11:14
VRB
15
1602
16:31
Operands
-
RT
Target General Purpose Register -
VRB
Source Vector Register -
MP
Mask Bit (0 or 1)
Example
vcntmbb r3, v3, 0
Related
More in VMX (AltiVec)
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Counts the number of byte elements in VRB that have bit 0 set to the value specified by MP (0 or 1), and places the count in the leftmost byte of the target GPR RT. This instruction is part of the VMX category and does not affect condition registers or status fields.
Operation
count ← 0
for i in 0 to 15:
if (VRB.byte[i][0] == MP) then
count ← count + 1
RT[56:63] ← count
RT[0:55] ← 0
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.