Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: IA-64 (Merced) missing bsf & bsr (re: Best way to extract n from 2^n)

Author: J. Wesley Cleveland

Date: 15:24:28 09/20/99

Go up one level in this thread


On September 17, 1999 at 15:56:37, Brian Richardson wrote:

>On September 17, 1999 at 10:14:19, Dave Gomboc wrote:
>
>>On September 17, 1999 at 10:00:47, Brian Richardson wrote:
>>
>>>On September 16, 1999 at 17:07:08, J. Wesley Cleveland wrote:
>>>
>>>>On September 15, 1999 at 16:57:30, Brian Richardson wrote:
>>>>
>>>>>I have looked at Intel's IA64 architecture guide and can't find these
>>>>>instructions, although there is a popcnt.  Am I missing something?
>>>>
>>>>There is a Compute Zero Index, which would allow you to do it in 3 instructions.
>>>
>>>I saw the czx instructions, but they find the first zero byte (or 2 bytes).
>>>How would you use czx to find the first non-zero element?
>>>Also, seems like table lookup would still be needed to find the first/last bit
>>>set?
>>
>>xor all of the bits first
>
>Ok, I assume you mean xor like compliment--that only switches 0s to 1s and vice
>versa.  Now, how does czx help, since it only finds all zero elements, wouldn't
>it only find the first zero element that originally was all ones, and not find
>any mixed 1s and 0s?

Its a little more complicated than I thought. do a pcmp1, =gr0 instead of an
xor. This will set any bytes containing a 1 to 0. then use the czx to find the
first one. Then shift it to the right, mask off the extra bits and do a table
lookup.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.