Bob Barr wrote: > Andy's code here will work if you need the value expressed in BCD and > not its actual hex value. > .... > If you need its true hex value, you'll need to multiply the msb > digit's numeric value by 10 (decimal) before adding it to the lsb's > numeric value. Oops, you're right. The correct code: LIST R = DEC MOVLW '0' BTFSC CHAR1,6 MOVLW 'A'-10 SUBWF CHAR1 MOVLW '0' BTFSC CHAR2,6 MOVLW 'A'-10 SUBWF CHAR2 CLRC ;Carry's always set here, so clear it. RLF CHAR1,W ;W = MSB * 2 SWAPF CHAR1 ;CHAR1 = MSB * 16 RRF CHAR1 ;CHAR1 = MSB * 8 ADDWF CHAR1,W ;W = (MSB * 8) + (MSB * 2) = MSB * 10 ADDWF CHAR2,W ;W = MSB * 10 + LSB > In either case, you can remove the BTFSC's and the MOVLW's following > them since the BTFSC will always skip the MOVLW. Bit 6 of your digit's > ASCII will always be clear for decimal digits '0' through '9'. True, but it'll be set for hex digits 'A' through 'F'. If the two input bytes are hex digits in the range 0-F, you need the BTFSC/MOVLWs; if they're only in the range 0-9, you don't. -Andy === Andrew Warren -- aiw@cypress.com === Principal Design Engineer === Cypress Semiconductor Corporation === === Opinions expressed above do not === necessarily represent those of === Cypress Semiconductor Corporation -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body