Bob Blick wrote: >I only have 22 cycles free at a time, and not always in the same place >in my p rogram, so I have to remember where I was in decoding and >parsing my input. Try this: ;ishex - convert the ASCII representation of a hex digit to a binary value ; Entry: W contains a character ; Exit: if the character was a valid hex digit ; ('0'..'9','A'..'F','a'..'f') ; return the corresponding value 00h..0fh, with STATUS.Z set ; else ; return with W *unchanged* and STATUS.Z clear ; ; 18 instruction words, 8 to 17 cycles (including return) ishex: addlw (255 - h'39') & h'ff' ;Check 0 - 9 addlw h'39' - h'30' + 1 btfsc STATUS, C goto in_range addlw 255 - h'66' + h'30' ;restore and change to upper addlw h'66' - h'61' + 1 btfss STATUS, C addlw h'20' addlw (255 - h'46' + h'41') & h'ff' ;Check A - F addlw h'46' - h'41' + 1 btfss STATUS, C goto out_of_range addlw h'0a' in_range: bsf STATUS, Z return out_of_range: addlw h'41' bcf STATUS, Z return Bob Fehrenbach