Sorry, couldn't help thinking about the best assembler version. This might be it:(untested!)
var byte data var bit parity var bit odd_parity=false -- make it true for odd parity assembler movlw 0 -- clear WREG btfsc odd_parity --check for odd parity addlw 1 -- and preload WREG:0 if odd xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG rrncf data,f -- rotate data by one bit xorwf data,w -- XOR data byte with WREG, now WREG[1:7] is full of even parity bits, while WREG[0] can be odd rrncf data,f -- rotate data by one bit for the eigth time to restore the original value bcf parity btfsc wreg,0 bsf parity end assembler So, it's 22 instructions and cycles, but no extra byte of ram :-) This can't be converted to pure jal easily, because jal (like most high-level languages) can only shift bytes, not rotate. Greets,Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/jallib. For more options, visit https://groups.google.com/d/optout.
