'Bit counting - Thanks all'
| 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.
______________________________ Reply Separator
Subject: Re: Bit counting (looking for old challenge emails)
Author: Regulus Berdin [SMTP:SKYINET.NET] at UKExchange rberdin
Date: 22/07/98 05:04
Hi to all,
> From: Scott Dattalo <UNIX.SRI.COM> sdattalo
> Thanks for the plug Bill. However, the routines on my web page are by
> means the fastest (as I've been shown). One PICLIST member has an
> isochronous bitcount routine that runs in 13 cycles. So unless he
> to post it, I guess there's a challenge for someone out there.
I took the challenge, here is what I got.
RRF Q,W ;Q = abcdefgh
MOVWF T ;T = 0abcdefg
ANDWF Q ;Q = 0b0d0f0h
ANDWF T,W ;W = 0a0c0e0g
ADDWF Q ;Q = (a+b)(c+d)(e+f)(g+h)
RRF T ;T = (xx)(a+b)(c+d)(e+f)
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.
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- New search...