Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Re: Challenge

2005-06-09 by Richard Austin

Paul Curtis wrote:
> Hi, 
> 
> 
>>>Indeed!
>>>
>>>I don't see a lot of this sort of thing anymore, here, or 
>>
>>on the piclist.
>>
>>>Used to be, several years ago..
>>>
>>
>>OK - how about another classic problem. Again, fine when you 
>>know but worth looking for a solution. Efficient code for 
>>counting the ones in an
>>8 or 16 bit value - say for a majority vote or some such.
>>
>>Pete Harrison
> 
> 
 From my days using 6502 for speed, use a look up table again - but is 
that code!

Or a simple loop. Relying on the bit shifted from the accumulator goes 
into the carry, then use ADC #0. This saves testing bits and any braches 
in code.

Something similar must be possible with AVR but I don't want to stick my 
neck out too far yet, only a starter after a long break!

Richard

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.