You're right Art, the LOOKUP method is quicker, but not by much versus the direct bit test method (checkbit8).
The real difference is that LOOKUP is a constant 27 instruction cycles since it is just a table lookup.
The downside as you and others state is the storage space of the table of 256 entries.
When you compile with the 256 entry LOOKUP table it consumes 556 codewords (973 bytes) of code space which is probably not worth the minor reduction in execution time.
The direct bit test (checkbit8 routine) does have variability in the performance based upon the input value (0-255) but if you look at the Max/Min execution time it is
(Max: 37 Min:10 Avg: 25) instruction cycles.
So comparing the two, worst case is that checkbit8 would be 10 inst cycles slower and best case is that checkbit8 would be 17 inst cycles faster and on average across the full (0-255) range checkbit8 is 2 inst cycles faster.
And checkbit8 only adds 116 codewords (203 bytes).
For these reasons my choice would be checkbit8 over the other options, except maybe pure ASM for those who are inclined.
Bookmarks