James & Ili wrote: > I remember a list discussion about parity generation a while back > but a search of the piclist archive doesn't turn it up. Could > someone share with me either the code, a pointer to the code or just > the theory of the code please ?? James & Ili: Here are the two routines I posted; Scott Dattalo and others posted routines, as well. ; ; Even parity generation in seven words / seven cycles. Enter with ; data byte in register "X"; exits with even parity in bit 1 (and ; also bits 2, 3, 4, and 5) of "X". ; PARITY_1: ; X: W: ; ------------ ------------ SWAPF X,W ; ABCDEFGH EFGHABCD ; XORWF X ; ABCDEFGH EFGHABCD ; xor EFGHABCD ; RRF X,W ; -ABCDEFG ; xor -EFGHABC ; XORWF X ; ABCDEFGH ; xor EFGHABCD ; xor -ABCDEFG ; xor -EFGHABC ; RRF X,W ; -ABCDEFG ; xor -EFGHABC ; xor --ABCDEF ; xor --EFGHAB ; RLF X ; BCDEFGH- ; xor FGHABCD- ; xor ABCDEFG- ; xor EFGHABC- ; XORWF X ; BCDEFGH- ; xor FGHABCD- ; xor ABCDEFG- ; xor EFGHABC- ; xor -ABCDEFG ; xor -EFGHABC ; xor --ABCDEF ; xor --EFGHAB ; ; This one takes 19 words, but executes in either 5 or 7 cycles, ; INCLUDING the test-and-branch at the end of the routine. ; ; Oh... And this one doesn't affect X, either. ; PARITY_2: SWAPF X,W XORWF X,W ANDLW 00001111B ADDWF PC GOTO ZERO GOTO ONE GOTO ONE GOTO ZERO GOTO ONE GOTO ZERO GOTO ZERO GOTO ONE GOTO ONE GOTO ZERO GOTO ZERO GOTO ONE GOTO ZERO GOTO ONE GOTO ONE ZERO: .... ONE: .... -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - Vista, California === http://www.geocities.com/SiliconValley/2499 (personal) === http://www.netcom.com/~fastfwd (business)