Hardware Support
Many architectures include instructions to rapidly perform find first set and/or related operations, listed below. The most common operation is count leading zeros (clz), likely because all other operations can be implemented efficiently in terms of it (see Properties and relations).
Platform | Mnemonic | Name | Word sizes | Description | Result on zero input |
---|---|---|---|---|---|
Intel 386 and later | bsf | Bit Scan Forward | 16, 32, 64 | ctz | Undefined, sets zero flag |
Intel 386 and later | bsr | Bit Scan Reverse | 16, 32, 64 | log base 2 | Undefined, sets zero flag |
AMD supporting SSE4.2 | lzcnt | Count Leading Zeros | 16, 32, 64 | clz | input size, sets carry flag |
Itanium | clz | Count Leading Zeros | 64 | clz | 64 |
ARM 5 or later | clz | Count Leading Zeros | 32 | clz | 32 |
IBM POWER/PowerPC | cntlz/cntlzw/cntlzd | Count Leading Zeros | 32, 64 | clz | input size |
MIPS | clz | Count Leading Zeros in Word | 32, 64 | clz | input size |
MIPS | clo | Count Leading Ones in Word | 32, 64 | clo | input size |
DEC Alpha | ctlz | Count Leading Zero | 64 | clz | 64 |
DEC Alpha | cttz | Count Trailing Zero | 64 | ctz | 64 |
Motorola 68020 and later | bfffo | Find First One in Bit Field | arbitrary | log base 2 | field offset + field width |
Notes: On some Alpha platforms CTLZ and CTTZ are emulated in software.
Read more about this topic: Find First Set
Famous quotes containing the words hardware and/or support:
“A friend of mine spoke of books that are dedicated like this: To my wife, by whose helpful criticism ... and so on. He said the dedication should really read: To my wife. If it had not been for her continual criticism and persistent nagging doubt as to my ability, this book would have appeared in Harpers instead of The Hardware Age.”
—Brenda Ueland (18911985)
“Those who, while they disapprove of the character and measures of a government, yield to it their allegiance and support are undoubtedly its most conscientious supporters, and so frequently the most serious obstacles to reform.”
—Henry David Thoreau (18171862)