Leftmost Bit Detection LMBD
3-141 Instruction SetSPRU733
Leftmost Bit DetectionLMBD
Syntax LMBD (.unit) src1, src2, dst
.unit = .L1 or .L2
Compatibility C62x, C64x, C67x, and C67x+ CPU
Opcode
31 29 28 27 23 22 18 17 13 12 11 5 4 3 2 1 0
creg z dst src2 src1/cst5 xop 1 1 0 s p
3 1 5 5 5 1 7 1 1
Opcode map field used... For operand type... Unit Opfield
src1
src2
dst
uint
xuint
uint
.L1, .L2 1101011
src1
src2
dst
cst5
xuint
uint
.L1, .L2 1101010
Description The LSB of the src1 operand determines whether to search for a leftmost 1 or 0
in src2. The number of bits to the left of the first 1 or 0 when searching for a 1
or 0, respectively, is placed in dst.
The following diagram illustrates the operation of LMBD for several cases.
1 1111111111111111111111111111111
x01xxxxxx xxxxxxxxxxxxxxxxx xxxxxx
xxxxxxx000 xxx0 1 x xxxxxxxx xxxxxxxx
When searching for 1 in src2, LMBD returns 4:
When searching for 0 in src2, LMBD returns 32:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
When searching for 0 in src2, LMBD returns 0: