How about a brute force approach ? splittens movlw 255 ;setup at 1 below 0 movwf tens movf number,w ;copy original number movwf units ;into units checktens incf tens,f ;=0 first time thru movlw 10 subwf units,f ;reduced by 10 until btfsc status,c ;below 0 or goto adjustit btfsc status,z ;hits 0, get out, goto checktens ;or not, so try again goto gotit adjustit movlw 10 ;gone too low, so addwf units,f ;fix up the units gotit itoa movlw 48 ;to convert the integers to ASCII addwf tens,f ;add the ASCII value for "0" addwf units,f ;to the integers bye. -----Original Message----- From: Nick Veys [mailto:nick@VEYS.COM] Sent: Thursday, 26 July 2001 15:07 To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: "itoa" routines? (16F870) Hi all. I'm in a bit of a tangle with some A/D input! I've been wrestling with a way to do this all night, which means I haven't thought of anything new, and won't! I have an 8bit number, only ranging 99 >= N >= 0 so it will only be 2 digits. I need to find a way to output it to my LCD... I have tried subtract and compare methods but they're huge and sloppy and I fear incorrect. Has anyone tackled this? My LCD output function spits out what is in W, I would *like* an "itoa"-like function that would break my 8-bit variable into 2 variables holding each digit, so I can then spit it out, but I am at a loss on how to do this effectively! (btw: my 100-line jump table didn't work out so well either! ;) nick@veys.com | www.veys.com/nick -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads ************************************************************************* This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of the New South Wales Department of Education and Training. ************************************************************************* -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics