>I'm looking for a nice efficient way to count the number of bits set in an >8-bit >register. I _know_ there were some nice pieces out there, but I can't seem >to >find one. How about: CBLOCK 0x0C Count Loop_Count ENDC clrf Count movlw 0x08 movwf Loop_Count clrc Loop rrf Number btfsc STATUS, C incf Count decfsz Loop_Count goto Loop Where "Count" holds the number of bits set. I don't know about "efficient," but I'm not sure how to do it faster offhand. or, by brute force: clrf Count btfsc Number, 0 incf Count btfsc Number, 1 incf Count ... etc. This would actually have fewer instruction cycles, but would take up just about twice the program memory. --Andrew _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.