Oops, we don't need to copy REGA, so it can be done even faster: ; Find median of REGA, REGB, REGC. MOVF REGB,W ;TEMP2 = REGB. MOVWF TEMP2 ; MOVF REGC,W ;MEDIAN = REGC. MOVWF MEDIAN ; SUBWF TEMP2,W ;TEMP2 >= MEDIAN? BC $+3 ;If so, skip ahead. ADDWF MEDIAN ;Otherwise, swap MEDIAN and SUBWF TEMP2 ;TEMP2. MOVF REGA,W ;MEDIAN >= REGA? SUBWF MEDIAN,W ; SKPC ;If so, skip ahead. SUBWF MEDIAN ;Otherwise, MEDIAN = TEMP1. MOVF MEDIAN,W ;TEMP2 >= MEDIAN? SUBWF TEMP2,W ; SKPC ;If so, skip ahead. ADDWF MEDIAN ;Otherwise, MEDIAN = TEMP2. 17 words, 16 or 17 cycles. -Andy === Andrew Warren - fastfwd@ix.netcom.com ------- End of forwarded message ------- === Andrew Warren - fastfwd@ix.netcom.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist