Opcode | Encoding | 16-bit | 32-bit | 64-bit | CPUID Feature Flag(s) | Description |
---|---|---|---|---|---|---|
VEX.L0.NP.0F38.W0 F3 /3 BLSMSK r32, r/m32 | vm | Invalid | Valid | Valid | bmi1 | Set the lower bits in r32 from bit 0 up to (and including) the lowest set bit of r/m32. |
VEX.L0.NP.0F38.W1 F3 /3 BLSMSK r64, r/m64 | vm | Invalid | Invalid | Valid | bmi1 | Set the lower bits in r64 from bit 0 up to (and including) the lowest set bit of r/m64. |
Encoding
Encoding | Operand 1 | Operand 2 |
---|---|---|
vm | VEX.vvvv[w] | ModRM.r/m[r] |
Description
The BLSMSK
instruction sets all the bits in the destination operand from position 0 up to (and including) the lowest set bit of the source operand. All other bits in the destination operand are cleared.
The operand size is always 32 bits if not in Long Mode. In other words, VEX.W1
is treated as VEX.W0
outside Long Mode.
Operation
public void BLSMSK(ref U32 dest, U32 src)
{
dest = (-src) ^ src;
}
public void BLSMSK(ref U64 dest, U64 src)
{
dest = (-src) ^ src;
}
Flags Affected
CF
(carry flag)- Set if the source is not zero. Cleared otherwise.
PF
(parity flag)- Undefined.
AF
(auxiliary flag)- Undefined.
ZF
(zero flag)- Cleared.
SF
(sign flag)- Set according to the result.
OF
(overflow flag)- Cleared.
Intrinsics
uint32_t _blsmsk_u32(uint32_t src)
uint64_t _blsmsk_u64(uint64_t src)
Exceptions
SIMD Floating-Point
None.Other Exceptions
VEX Encoded Form: See Type 13 Exception Conditions.