[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Faster bit count on 680x0
A few ways of counting bits without a lookup table were proposed.
Here's a method that should be faster:
; (preamble)
move.w (source)+,d0
clr.w d1
clr.w d2 ; bit count
; body of code that counts bits
repeat 16 ; repeat the following section of code 16 times:
add.w d0,d0 ; shift most significant bit into carry
addx.w d1,d2 ; add zero in d1 plus carry bit to bitcount in d2
rpe ; end of repeated section
The result in d2 is the number of 1 bits in (source). The repeated
section of code is 64 bytes long, well under the cache size of an '020,
so it can be repeatedly executed to count multiple source words without
having to reload the instruction cache.
My duties at Apple have constrained how much I can do for speech
compression at modem rates (a project I want to do for secure phone
applications, Cypherpunk style) but if anyone has some 68K code they'd
like optimized, drop me email. Freeware type efforts preferred-- I
already have a job :)
- Jim Nitchals
QuickTime engineering team
Apple Computer, Inc.