Reginald Neale wrote: > Does anyone have a favorite way to do a window comparison on an > A/D result? .... What I want to do is to insert code in an existing > loop that will set an alarm output pin if the A/D result falls > outside the window; set another pin high if it is below the > hard-coded lower limit, set a different pin if it is above the > upper limit, and continue on without setting any of the three if > the result is within the window. Reg: Try this; I haven't even assembled it, let alone tested it, but it SHOULD work... MOVF ADRES,W ADDLW 256-UPPER ;These 4 lines were written by ADDLW (UPPER-LOWER)+1 ;a smart guy named Eric Smith. SKPNC ; GOTO DONE ; ;Our A/D result was outside the [LOWER-UPPER] window. BSF ALARMPIN ;Set the ALARM pin. ADDLW LOWER-1 ;Was ADRES too low? SKPC ;If so, skip ahead. BSF HIGHPIN ;Otherwise, set the HIGHPIN pin. SKPNC ;If ADRES was too high, skip ahead. BSF LOWPIN ;Otherwise, set the LOWPIN pin. DONE: -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - San Diego, California === http://www.geocities.com/SiliconValley/2499