RE: [AVR-Chat] Exclusive or
2004-06-19 by Dave Hylands
I think that the fastest way is to have a sixteen entry lookup table, where the answer is precomputed and stored. You could also store a 16 bit value, where each bit position holds the answer and use something like (in C): Lookup & ( 1 << val ) Where lookup is the 16 bit bit vector and val is the 4 bit value you're trying to extract. I think this is slower, but would take up less memory. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/
Show quoted textHide quoted text
> -----Original Message----- > From: David VanHorn [mailto:dvanhorn@cedar.net] > Sent: Friday, June 18, 2004 8:47 PM > To: AVR-Chat@yahoogroups.com; AVR-Chat@yahoogroups.com > Subject: [AVR-Chat] Exclusive or > > > > 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.