Not elegant but seven instructions and free: movf X,W ; get first number. subwf Y,W ; sub second number. bc AA ; result positive? - Yes, go to AA. xorlw h'FF' ; convert from two's compliment addlw 1 ; negative to positive. AA subwf DIFF,w ; sub difference from DIFF. bc LESS ; result + or 0? - Yes, goto LESS. On Tue, 13 Jan 1998 11:49:18 EST, you wrote: ->Happy New Year, -> I was just wondering if anyone has an elegant method for determining ->whether two numbers are within an absolute difference, in the 12 bit PIC ->universe. -> -> For example... the two numbers, X & Y, are in registers which must ->remain unchanged are to be tested to determine whether they are within ->DIFF of each other. -> -> My first try this year is: -> -> MOVF X,W ;Try it this way -> SUBWF Y,W -> -> SKPNC ; Positive? -> GOTO POS ; Yes -> -> MOVF Y,W ; No, then do it the other way -> SUBWF X,W -> ->POS SUBWF DIFF,W ; Compare against the limit -> -> SKPNC ; The carry knows... -> GOTO LESS -> -> ->Thanks in advance, -> Jen :-)