How's this? I had to use a temp register though: movf file1,w subwf file2,w btfsc STATUS, C goto $ + 2 movf file1,w goto $ + 1 movf file2,w movwf temp subwf file3,w btfsc STATUS, C goto $ + 2 movf file3,w movwf temp movf temp,w Cheerful regards, Bob Blick > Here's a design challenge for you guys: > > I have values in three file registers: fileA, fileB, fileC. > > I want to choose the value that's in the middle (numerically) and put it > into W. > > The brute-force way to do this would be to copy the list, sort the > copy in place, and choose the middle value. > > I'm sure there's a more direct way. Any ideas? > > (Application: This a simple nonlinear filter to remove occasional > outliers in a sampled data stream.) > > Regards, > Mark > markrages@gmail -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist