Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

RE: [AVR-Chat] Exclusive or

RE: [AVR-Chat] Exclusive or

2004-06-20 by Dave Hylands

Hi Wagner,

The following comninations will also yield a 1:

0111
1011
1101
1110

I think that David made a mistake on his 0111 entry.

To check that only one bit is set is the same thing as saying that a
number is a power of two.

If the expression ( x & ( x - 1 )) yields zero, then x is a power of
two.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/ 
Show quoted textHide quoted text
> -----Original Message-----
> From: wagner [mailto:wagner@ustr.net] 
> Sent: Sunday, June 20, 2004 11:28 AM
> To: AVR-Chat@yahoogroups.com
> Subject: Re: [AVR-Chat] Exclusive or
> 
> 
> 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.
> 
> 
> That is a very tricky question.
> 
> If you assume literaly "Exclusive Or" for 4 bits, you are 
> stating that when JUST ONE bit is UP you will have output UP, 
> it means, only the following combinations will have output UP:
> 
> 0001
> 0010
> 0100
> 1000
> 
> I can think of many fancy ways to verify that, including 
> digital external and even a jaw dropping 5 resistors tied to 
> 4 output pins to read an analog voltage via an adc to 
> identify just one output pin up, but not so simply as 4 easy 
> comparisons for 1, 2, 4 and 8.  This could be done in few 
> different ways, a loop with a binary shifting 4 comparisons, 
> pure 4 comparisons with fixed values, etc.
> 
> Wagner
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.706 / Virus Database: 462 - Release Date: 6/14/2004
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> --------------------~--> 
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free! 
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dN_tlB/TM
> --------------------------------------------------------------
> ------~-> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.