Mail Archives: djgpp/1999/08/13/19:03:48
Try this little function, I guess it may gain if written in assembly
though ..
/*
* Ones
*
* This magic counts the number of bits in one longword
*/
int
Ones(unsigned long mask)
{
register unsigned long y;
y = (mask >> 1) & 033333333333;
y = mask - y - ((y >>1) & 033333333333);
return (int) (((y + (y >> 3)) & 030707070707) % 077);
}
Regards,
Kurt Alstrup
PS. This is the 2nd reply, the 1st one came back with the note
----- The following addresses had delivery problems -----
<djgpp AT delorie DOT com> (unrecoverable error)
----- Transcript of session follows -----
... while talking to delorie.com.:
>>> DATA
<<< 500 Hey, offensive language ("d|a|m|n") is not allowed.
<dj AT delorie DOT com>
554 <djgpp AT delorie DOT com>... Remote protocol error
----- Original message follows -----
As I just replied to mail message I originally got from the djgpp
mailing list I fail to
understand why the original mail got through in the first place.
Secondly I disagree
that it was offensive languange, propably strong, but offensive;
definitely no.
Anders David Skarin wrote:
> Hi,
>
> What is the fastest way (or just a <<CENSORED, d|a|m|n>> fast way) to
> count the nr of binary 1's in a byte/word/dword ?
>
> Is there any assembler instruction for this ?
> (there should be, considering the nr of instructions
> in the sisc processors)
>
> Thanks!
>
> David Skarin
- Raw text -