Searching \ for 'Bit counting - Thanks all' in subject line. ()
Make payments with PayPal - it's fast, free and secure! 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.
PICList Thread
'Bit counting - Thanks all'
1998\07\22@050644 by Steve Lawther

flavicon
face
    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


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


Hi to all,

> From: Scott Dattalo <.....sdattaloKILLspamspam@spam@UNIX.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
     ADDWF Q           ;Q = (a+b)(c+d)(e+f)(g+h)

     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)
     ADDWF Q           ;Q = (a+b+c+d)(e+f+g+h)

     SWAPF Q,W         ;W = (e+f+g+h)(a+b+c+d)
     ADDWF Q,W         ;W = (a+b+c+d+e+f+g+h)(a+b+c+d+e+f+g+h)
     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...