www.piclist.com/techref/microchip/math/index.htm?key=math

Hi,

Philip Martin wrote:

>I have got a routine to convert 16 or 24 bit to BCD and that works

fine. But

>what I need is a routine to convert BCD to 16 bit, does anyone know the

>location of such a routine or, how best to go about this.

Well there is a very easy way ( albeit fairly slow :) ) ( I'm using

it as I get digit by digit entered on keyboard ( and user input

tend to be slow if compared to pic-speed :) ) Anyway here goes:

In the case of a 24 bit variable 'allocate' 3 bytes of data

clear them. Add the left mostdigit, multiply by 10 add the next

digit etc. etc. *very* easy albeit slow as said.

24bit*10 can be generated by the code generator.

There are faster way to do this but sofar I haven't had the need for

such an routine.

/Tony

Tony Kübek, Flintab AB

²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²

E-mail: spamBeGonetony.kubek.....spam_OUTflintab.com

²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²

--

http://www.piclist.com hint: The PICList is archived three different

ways. See http://www.piclist.com/#archives for details.

See also: www.piclist.com/techref/microchip/math/index.htm?key=math