Bob Barr wrote: > The input digits do have to be in the ASCII '0'-'9' range (otherwise > doing the '* 10' wouldn't be right.) > > Royce's original input data is a pair of decimal characters to be > converted to hex. The characters 'A' through 'F' just can't be part of > valid input data. See? THIS is what happens when you take a perfectly good software guy and make him work on everything BUT software for a year and a half. Sigh... Ok, my code and I were both confused. Here's the routine to translate two ASCII hex digits (0-9 or A-F) into a hex value. I don't remember Royce saying that his two ASCII digits were decimal, so this might be what he wanted: LIST R = DEC MOVLW '0' BTFSC CHAR1,6 MOVLW 'A'-10 SUBWF CHAR1 MOVLW '0' BTFSC CHAR2,6 MOVLW 'A'-10 SUBWF CHAR2 SWAPF CHAR1,W ADDWF CHAR2,W (By the way... On piclist.com, there's a code fragment attributed to me which purports to perform the above translation. It contains two extra lines between the SWAPF and the final ADDWF; I have no idea how those lines got there, and can only assume that the code was taken out of context.) Here's the code to translate two ASCII decimal digits (0-9) into a hex value. If Royce's input characters ARE decimal, this is the routine he wants: LIST R = DEC MOVLW '0' SUBWF CHAR1 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 -Andy === Andrew Warren -- aiw@cypress.com === Principal Design Engineer === 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