Searching \ for 'Bit counting - Thanks all' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/timers.htm?key=count
Search entire site for: 'Bit counting - Thanks all'.

Truncated match.
'Bit counting - Thanks all'
1998\07\22@050644 by

To all on the PIClist,

Thanks for the help in finding the bit counting code. Yes I was
looking for one's bits counting, not parity.

The likes of the code below is exactly what I was looking for.

Steve Lawther

_________________________________
Subject: Re: Bit counting (looking for old challenge emails)
Author:  Regulus Berdin [SMTP:rberdinSKYINET.NET]  at UKExchange
Date:    22/07/98 05:04

Hi to all,

> From: Scott Dattalo <sdattaloUNIX.SRI.COM>
[SNIP]
> Thanks for the plug Bill. However, the routines on my web page are by
no
> means the fastest (as I've been shown). One PICLIST member has an
> isochronous bitcount routine that runs in 13 cycles. So unless he
wishes
> to post it, I guess there's a challenge for someone out there.

I took the challenge, here is what I got.

BITCOUNT:               ;untested
RRF   Q,W         ;Q = abcdefgh
MOVWF T           ;T = 0abcdefg
MOVLW B'01010101'
ANDWF Q           ;Q = 0b0d0f0h
ANDWF T,W         ;W = 0a0c0e0g

RRF   Q,W
MOVWF T
RRF   T           ;T = (xx)(a+b)(c+d)(e+f)
MOVLW B'00110011'
ANDWF Q           ;Q = (00)(c+d)(00)(g+h)
ANDWF T,W         ;W = (00)(a+b)(00)(e+f)

SWAPF Q,W         ;W = (e+f+g+h)(a+b+c+d)
ANDLW H'0F'       ;W = (0000)(a+b+c+d+e+f+g+h)

Data is in Q and result is placed in W.

The routine is isochronous but 16 cycles. I cannot shave
it down to 13 or less :(.  I wonder how this piclist member
did it or what method/algorithm he used.

Reggie

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...