Ed, if the setpoint is a variable then the standard way to do it is this: movf point_low, w ;subtract lower subwf ADRESL, f ;byte as usually movf point_high, w ;subtract higher byte skpc ;and handle incfsz point_high, w ;borrow from previous subtraction subwf ADRESH, f This can be extended for 3 and more bytes by using the 4 instruction subtraction with carry in and carry out (as for the higher byte above) for each additional byte. If you don't need to know the result of subtraction, but need simply the carry flag, then the subwf instructions can be changed to put the result in accumulator, like: movf point_low, w ;subtract lower subwf ADRESL, w ;byte as usually movf point_high, w ;subtract higher byte skpc ;and handle incfsz point_high, w ;borrow from previous subtraction subwf ADRESH, w It can be translated directly to a constant subtraction: movlw POINT_LOW ;or (POINT & 0xFF), if setpoint defined in POINT subwf ADRESL, w movlw POINT_HIGH ;or (POINT >> 8) skpc ;and handle movlw POINT_HIGH+1 ;or (POINT >> 8) + 1 subwf ADRESH, w However, there is no incfsz instruction for accumulator, so this example doesn't work when POINT_HIGH equals 0xFF. See also: http://www.piclist.com/techref/microchip/math/basic.htm http://www.piclist.com/techref/microchip/codeflow.htm and AN617 note for integer arithmetics at http://www.microchip.com/10/Appnote/Category/Library/00617/index.htm Cheers, Nikolai ---- Original Message ---- From: Ed Bockhoefer Sent: Wednesday, February 14, 2001 16:42:27 To: PICLIST@MITVMA.MIT.EDU Subj: [pic]:Using the 10 bit a/d > Does anyone know how to do a simple command like subwf for the 10 bit a/d > converter. I'm trying to set an led from an analog signal (ADRESH,ADRESL) > and a 10 bit set point value but I can't seem to find anything on the web > site FAQ or come up with an algorithm to do it across the two bytes needed. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body