>Harry wrote: >> Does anybody have a routine for implementing bit reversal ? > i.e. 11000000 to be converted to 00000011 >This topic has just been discussed in the PIC16CXX forum on the >Microchip BBS (see messages 127246,127625 and 127775). Here is the >solution given by Mark Palmer of Microchip: >CLRF REVERSE ; Precondition Register to 0 >BTFSC NORMAL, 7 ; MSb set? >BSF REVERSE, 0 ; Set LSb ... etc... here's another solution, but I'm no pic expert, so I don't know if this would be faster and/or shorter than the above solution... // ad_value: abcd efgh ad_value=((ad_value<<4)&0xf0)|((ad_value>>4)&0x0f); // efgh abcd ad_value=((ad_value<<2)&0xcc)|((ad_value>>2)&0x33); // ghef cdab ad_value=((ad_value<<1)&0xaa)|((ad_value>>1)&0x55); // hgfe dcba John Maushammer jmaushammer@SMTPLINK.CTA.COM