Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Exclusive or

2004-06-19 by Russell Shaw

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.

unsigned char i,reg,odd=0;
reg=<???>;
for(i=0;i<8;i++){
   if(reg&1)
     odd=!odd;
   reg>>=1;
}

Attachments

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.