unsigned char rev(unsigned char ch) { unsigned char m=1,n=128,ch1=0; int i; for(i=0;i<8;i++) { ch1|=ch&m?n:0; m<<=1; n>>=1; } return ch1; }