Thanks All, I really appreciate all the answers. The code below is what I was looking for. I had worked on this this morning and I had almost the code below but I did not use the neat trick of setting up a default subtraction value before testing the input character. I am learning slowly but well, I think. I had 2 hex characters (0 to F) for input and I needed the get the result in the W reg as a hex number, ex: IN = A1 (ASCII), output = A1 (HEX). Works great, Royce ----- Original Message ----- From: Andrew Warren To: Sent: Monday, February 04, 2002 7:59 PM Subject: Re: [PIC]: ASCII to HEX > 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' HERE IS THE NEAT TRICK, SET THE CONSTANT > BTFSC CHAR1,6 TEST > MOVLW 'A'-10 CHANGE THE CONSTANT > SUBWF CHAR1 > > MOVLW '0' > BTFSC CHAR2,6 > MOVLW 'A'-10 > SUBWF CHAR2 > > SWAPF CHAR1,W > ADDWF CHAR2,W > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body