Hi Ronald, The "addlw 0 - x" instruction is a quick and dirty way of doing an explicit subtraction from "w". addlw 0 - x is equivalent to: w = w + ( 0 - x ) = w - x "sublw" is an instruction I try to avoid whenever possible. That's because: sublw x is equivalent to: w = x - w = x + (( w ^ 0x0FF ) + 1 ) ; This is how the PIC handles sub I, personally, find this very hard to keep straight in my mind (especially with what it does to the Status bits). I also find few instances where subtracting the contents of w from a constant useful. Actually, I lie, there is one *very* useful application for "sublw" and that is to negate the value in "w" and that's done by: sublw 0 ; Negate the value in "w" I find there are two real areas you have to understand well in the PIC. The first is how PC changes work (goto and tables using PCLATH) and subtraction. Good Luck, Myke >Myke, Keith, > >thanks for your help sofar. > >While you were cooking up your solutions I devised the following possible >solution. >What I did not mention is that inloc and outloc are buffer pointers that >cycle over the values 0x0c and 0x24. > >My solution, if it works which I don't know yet: > > ; if inloc is within bufmax places of outloc then hold input > ; if out > in then if (out - in) < 5 hold > ; else if out < in then if (in - out) > 19 hold > movf InLoc, W > subwf OutLoc, W > btfss _c ; if C = 1 then inloc > outloc ((out - in) in W) > goto inGTout > sublw 5 > btfsc _c > goto hold > goto RestoreIntStatus ; else ready >inGTout: ; test if in-out > 19 > movf OutLoc, W > subwf InLoc, W > sublw D'19' > btfsc _c ; > goto RestoreIntStatus ; else ready >hold: > data_off ; no more data please > > >One question about Myke's solution: >In PIC assembler, using "w" as "temp", this would be: > > movf outloc, w > subwf inloc, w > btfss STATUS, C ; Skip Next if we don't have a Negative > sublw 0 ; Make the Negative Positive > >>>>> addlw 0 - 4 ; Subtract 4 from the absolute value > btfsc STATUS, C > goto X ; Value is Greater than 4... > > >I don't understand the addlw 0 - 4 line. It is supposed to substract. >Shouldn't it read sublw 4 > > >Ronald > > Do you ever feel like an XT Clone caught in the Pentium Pro Zone?