On Sat, 18 Nov 2000, Jason Harper wrote: > Simon Nield wrote: > > the problem: > > i need to biphase code a byte for serial transmission over an rf link. > > in other words each '1' becomes '10' and each '0' becomes '01'. > > if it makes the code easier then '1' becoming '01' and '0' becoming '10' > is ok too. > > > > this _could_ be done with a lookup table, which would be fast, but that's > not the point of a tiny > > code challenge now is it ? > > Is there any particular requirement that the bits be sent in their original > order? If not, send every other bit on each pass - that way, you don't > have to shift them as far from their original location. That's what I was going to suggest - well not exactly, but something close. I was going to say it's probably more efficient to manchester encode as you go along. But if we take your approach, it can be optimized: movf byte_to_send,w andlw b'01010101' addlw b'01010101' movwf temp1 rrf byte_to_send,w andlw b'01010101' addlw b'01010101' movwf temp2 call send_bits > > movf byte_to_send,w ;abcdefgh > andlw b'01010101' ;0b0d0f0h > movwf temp > clrc > rlf temp,w ;b0d0f0h0 > iorwf temp,w ;bbddffhh > xorlw b'10101010' ;BbDdFfHh > call send_byte > > movf byte_to_send,w > andlw b'10101010' > movwf temp > clrc > rrf temp,w > iorwf temp,w > xorlw b'10101010' ;AaCcEeGg > call send_byte > Sending the bits is a little more challenging. I'll propose one solution off of the top of my head: movf IOPORT,w andlw IOPORT, ~(1<uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads