Henrik Holmgerd wrote: > Hi all > I have a project where I have to convert a 32 bit binary or hex number to > ASCII to be displayed on a LCD. Does some one on this list have done this > before, if so are you willing to share the solution with me or give me some > hints. I have done decimal to ASCII conversion no problem, but now my > project end up with a 32 bit number and then I have only very complicated > solutions. > Here's my Hex to ASCII . You need only do the word to nibble conversion. ;****************************** HEX to ASCII ********************************** ; Converts a HEX nibble, passed in "W", returned in "W". ;****************************************************************************** HEX2ACSII MOVWF ADJ_CHAR ; Save the HEX nibble. MOVLW '0' ; Form the character "0". ADDWF ADJ_CHAR,F ; Convert a 0-9 HEX nibble to a Character. MOVLW '9' ; Form the character "9". SUBWF ADJ_CHAR,W ; Test the new character. BTFSC STATUS,Z ; Is the new character a Nine? GOTO H2A_Exit ; Yes, Return sucessful. BTFSS STATUS,C ; No, Does the new character need further adjust? GOTO H2A_Exit ; No, Return sucessful. MOVLW 0x07 ; Yes, Form the Alpha character adjust. ADDWF ADJ_CHAR,W ; Convert a A-F HEX nibble to a Character. RETURN ; Done. ; H2A_Exit MOVF ADJ_CHAR,W ; Fetch the adjusted (HEX) character. RETURN ; Done. > > tnx in advance. > > \||||||/ > _____oo0o__( o o )__o0oo_____ > (_) > > Henrik Holmgerd -- * | __O Thomas C. Sefranek tcs@cmcorp.com |_-\<,_ Amateur Radio Operator: WA1RHP (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz ARRL Instructor, Technical Specialist, VE Contact. http://hamradio.cmcorp.com/inventory/Inventory.html http://www.harvardrepeater.org