On 18 Jun 2004 at 22:47, David VanHorn wrote: > > What's the fastest way to get the exclusive or, of four bits in a register? > > 0000 = 0 > 0001 = 1 > 0010 = 1 > 0011 = 0 > 0100 = 1 > 0101 = 0 > 0110 = 0 > 0111 = 0 > and so on... > > Not for a parity generator, but I think it ends up as the same problem. > clr sum sbrc tmp,0 inc sum sbrc tmp,1 inc sum sbrc tmp,2 inc sum sbrc tmp,3 inc sum Another way: clr sum lsr tmp adc sum, tmp lsr tmp lsr tmp adc sum, tmp The XOR of the four 'tmp' bits is in 'sum', bit 0. HTH. Mark Jordan
Message
Re: [AVR-Chat] Exclusive or
2004-06-19 by Mark Jordan