reversing a mask

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Nov 26 05:46:11 AEST 1984


> >What's the fastest way to reverse a 16-bit mask in C?  In 68000 asl?
> 
> Actually the 65536 combination answer wasn't too far from a plausible
> method - split the word up into 2 8 bit bytes and then do two lookups.
> Then swap bytes.  This way you only need one 256 byte table.
> 
> You could do lookups on nybbles, etc, ad nauseum.

Hey!  Take this to the logical extreme:  split into 16 1-bit fields,
then you can dispense with the table altogether (since the reversal
of a 1-bit field is itself).  :-)



More information about the Comp.lang.c mailing list