Maybe this will help. It may not be the most efficient routine but it works If you have 2 ASCII bytes '2' (0x32) and '3' (0x33) call the Asc2Hex routine with the register Tmp containing 0x33 and Tmp+1 containing 0x32. When the routine finishes the WREG will contain 0x23. You may need to nodify this to filter your junk charachters. If you do maybe you would be kind enough to send me a copy. It was'nt an issue for me when I wrote this. The code was written for a 17c44 but should be easily ported for other stuff Asc2Hex movlw 0x40 ;Check data for A to F cpfsgt Tmp goto NumLo AlphaLo movlw 0x37 subwf Tmp,WREG goto SaveLo NumLo movlw 0x30 ;Check data for 0 to 9 subwf Tmp,W SaveLo andlw 0xf ;Save in the lo nibble of the reg movwf Tmp movlw 0x40 ;Check data for A to F cpfsgt Tmp+1 goto NumHi AlphaHi movlw 0x37 subwf Tmp+1,WREG goto SaveHi NumHi movlw 0x30 ;Check data for 0 to 9 subwf Tmp+1,W SaveHi andlw 0xf ;Save in the hi nibble of the reg swapf WREG addwf Tmp,WREG return The Hex2Asc routine does the opposite You call it twice for each byte you want to convert to it's ASCII representation as follows movfp INDF1,WREG ;Byte to be converted is pointed to by IN DF1 movwf Tmp ;Move byte to be converted to Tmp movlw 0xf0 ;Convert high nibble andwf Tmp swapf Tmp call Hex2Asc movfp INDF1,WREG movwf Tmp ;Move byte to be converted to Tmp movlw 0x0f ;Convert high nibble andwf Tmp swapf Tmp call Hex2Asc Hex2Asc ;A nibble of the byte to convert is in Tmp bcf Carry movlw 9 subwf Tmp,WREG btfss Zero btfss Carry goto ZNumHi bcf Carry movlw 37 addwf Tmp movfp Tmp,WREG return ZNumHi movlw 30 addwf Tmp movfp Tmp,WREG ;ASCII byte is in WREG return At 14:51 28/05/99 -0700, you wrote: >Does anyone have a nice code snippet that takes a byte containing a hex >character (0x30 through 0x39 and 0x41 through 0x46) and converting it to a >plain numeric byte, 0x00 through 0x0F? Everything that comes to mind seems >wasteful and clunky. > >The character coming in may also contain junk that must be filtered out. > >Thanks! > >Happy long weekend if you get one. Cheers, >Bob > >