On Thu, Jun 26, 2003 at 05:43:23AM +0100, Sergio Masci wrote: > If I understand correctly you are clocking in all bit 7's followed by all bit > 6's down to all bit 0's > > Try the following: > > acc = 0 > > for (int j=0; j<8; j++) > { acc = (acc << 1) + count_one_bits(read_port()) > } > > count_one_bits() could be implemented as a lookup table It's more efficient to do directly. Each loop iteration can be done in 15 cycles, if you unroll it and add the "acc=0" at the begining, you get 15*8+1 = 121 cycles (and 121 program words). Seems that it's the faster version. Daniel. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads