Hi > I posted this code which tests whether the value in the W register lies > within a range: > > addlw 256-hival > > addlw (hival-loval)+1 > > btfsc status,cf > > goto inrange > > To which John Payson replied: ... > And to which Adrian Kennard replied: ... > Sometimes I wonder why I bother trying to share code at all. I could be > working on paying jobs rather than wasting time defending code I'm giving > away. Hold on there, don't blow your stack. I for one am impressed with your code and appreciate you sharing it with the group. I find that I use code to trim values all the time and have always wondered if there's a faster way to do it. To trim the value in val between MIN and MAX I use: movlw MIN ; get min value subwf val,w ; w = val - MIN btfss status,cf ; if val < MIN subwf val,f ; then val = MIN movlw MAX ; get max value subwf val,w ; w = val - MAX btfsc status,cf ; if val >= MAX subwf val,f ; then val = MAX Greg Solberg greg@acmeart.com