| Jannie Hamman 
 
 
 Joined: 16 Sep 2003
 Posts: 6
 Location: South Africa
 
 
			      
 
 | 
			
				| Manchester code included |  
				|  Posted: Thu Sep 21, 2006 9:55 am |   |  
				| 
 |  
				| Here is working code: Enjoy...
 
 
 //Encode a byte to Manchester code
 long enman(int this){
 long man;
 int i,lob,hib;
 #bit tbit=this.0
 lob=man;
 for(i=0;i<4;i++){
 shift_right(&lob,1,tbit);
 shift_right(&lob,1,!tbit);
 rotate_right(&this,1);
 }
 hib=hi(man);
 for(i=0;i<4;i++){
 shift_right(&hib,1,tbit);
 shift_right(&hib,1,!tbit);
 rotate_right(&this,1);
 }
 man=lob;
 hi(man)=hib;
 return(man);
 }
 
 //Decode Manchester code to original byte
 int decman(long this){
 int i,temp,out;
 #bit tbit=temp.0
 temp=this;
 out=0;
 for(i=0;i<4;i++){
 shift_right(&out,1,tbit);
 rotate_right(&temp,1);
 rotate_right(&temp,1);
 }
 temp=hi(this);
 for(i=0;i<4;i++){
 shift_right(&out,1,tbit);
 rotate_right(&temp,1);
 rotate_right(&temp,1);
 }
 return(out);
 }
 _________________
 Cheers,
 
 Jannie
 |  |