> > Actually, subtraction in the PIC adds the Negative to the number: > > SUBLW 0x06 > > Is Actually: > > w = 6 + (( w ^ 0x0FF ) + 1 ) > > This leads to all kinds of wild and wonderful things. Before using either > subtract in the PIC, write a few of simple programs to experiment with > subtract and see what the results are before using them in the program. > > >the trick i use to get around this one is to add -6 > > > > ADDLW 0x00-0x06 ; subtract 6 from W > > Good Trick and one that is more intuitive than using the "SUBLW" instruction. > > myke Myke is right. Try the test cases for -1 , 0 , 1. Of the many different ways that the various processors that we work on do subtracts the "0" case is the most unpredictable in setting thne condition codes. The carry reflects the last operation the following with the addition of one more set of brackets show's the Microchip PIC familly subtract. w = (6 + (( w ^ 0x0FF ) + 1 )) Walter Banks