Nicholas wrote: >>Hi all, >> >>I need to use even parity, 1 stop bit with 7 data bits. I can quite >>easily transmit 8 data bits and no parity but my question is "what would >>be the best way of implementing even parity and 7 data bits." Has >>anybody got a snippet of code I could look at (or even pseudo code) or >>maybe a web site to goto? >> >>Thanks for any advise, >>Brian. > >I'm sure some people have some optimised algorithms out there but >one usefull thing to remember is that XOR can be looked at as a >1 bit add applied in parallel (ie 8 times) to each bit in the byte >Thus by shifting bits and swapping nibbles you can arrange to calculate >the parity which is just the sum of all bits. > >; enter with data in W exits with parity in bit 7 of W >temp equ Scratch_Register > movwf temp > swapf temp,F > xorf temp,F > rlf temp,F > rlf temp,F > xorf temp,W > movwf temp > rlf temp,F > xorf temp,W Nicholas, I couldn't get this to work. Will it work on a 16C74? What does the line xorf temp,W mean... do you mean xorwf temp,W? If you did, I still can't see it working. Thanks, Brian.