Walter Banks wrote: > A more common compiler requirement is do this > kind of operation with out changing register C > unless it is needed. ie pre-setting C has lots > of problems if C is volitile. I think that will take > 6 instructions. (can it be done in less?) > > btfsc A > btfss B > goto clear > bsf C > goto done > clear bcf C > done Walter: IF bit "A", bit "B", and bit "C" are at the same locations in their respective bytes, and IF C isn't really "volatile", but you just want to avoid a quick glitch on it, you can do it in five instructions/cycles: MOVF BYTE_A,W ANDWF BYTE_B,W ANDLW 00000001B ;Assumes that bit_A and bit_B are the LSB ;of BYTE_A and BYTE_B, respectively. XORWF BYTE_C,W ;Byte_C must not change between this ;instruction and the next one. XORWF BYTE_C Since all of the above conditions aren't likely to be true in the general case, this bit of code is really only useful when BYTE_C is an I/O port and BYTE_A and BYTE_B are user-defined flag registers that have been specifically ordered so as to put bit_A and bit_B in the same bit-position as bit_C. As I said, it's not the general case (and it's not particularly applicable to compiler design for that reason), but it's common enough that if someone's writing his code in assembly, he should be able to use this method without going to too much trouble. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - Vista, California === http://www.geocities.com/SiliconValley/2499 === For PICLIST help (including "unsubscribe" instructions), === put the single word "help" in the body of a message and === send it to: listserv@mitvma.mit.edu