On Thu, 11 Jun 1998 11:50:00 PDT "Clewer,Brian" writes: >James Cameron wrote: > >>Clewer,Brian wrote: >>> My problem is that I have an 8 bit byte and I need to convert it >>> into two printable chars to send to my PC. E.g.. 00111001 would >be >>> 39 (in hex). I need to send the two chars 3 and 9 to my PC. [non-working routine removed] >Any more ideas? Here's what I use. It's rather generic. You need a temporary register "tmp" and a subroutine called "serout" that sends W to the PC. Enter by calling "serout2dig" with the number in W. It will send two ASCII digits that represent the number in hexadecimal. Note the conversion routine uses the ADDLW instruction, which isn't present on 12-bit PICs. ;------ serout2dig ; Outputs W as 2 hexadecimal or packed BCD digits. The high 4 bits are ; output first so they appear leftmost on the terminal screen. ; Uses tmp. On exit, a copy of the original W is in tmp. movwf tmp swapf tmp,w ;Get first (high) digit. call seroutdig movfw tmp ;Get second (low) digit. ; FALL THRU to seroutdig. ;------ seroutdig ; Outputs low 4 bits of W as a BCD or hexadecimal digit. High 4 bits ignored. ; W is erased. Exits via serout. andlw b'00001111' ;Keep only low 4 bits. addlw 0 - .10 ;Less than 10? skpnc ;Yes, OK. addlw 'A' - ('9' + 1) ;If >9, fix as a letter. addlw '0' + .10 ;Offset back up to ASCII. goto serout _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]