piclist 2001\01\19\174655a >
www.piclist.com/techref/microchip/math/index.htm?key=math
BY : Don Hyde email (remove spam text)

Multiplying by 10 in binary can be quite fast and simple:

10 = 8+2 = 2^3 + 2

Multiplication by a power of two can be accomplished by shifting, so in C

result = input*10;

can be written

result = input<<3 + input<<1;

or, more efficiently on some machines (such as PIC's):

result = ((input<<2)+input)<<1;

For 16 bits in assembler:

cblock  0x20
input:2 ;little-endian, i.e. least significant byte first
result:2
endc

Multiply_by_10:
movfw   input                   ;result = input
movwf   result
movfw   input+1
movwf   result+2

clrc                            ;result = result<<2
rlf     result,f
rlf     result+1,f
clrc
rlf     result,f
rlf     result+1,f

movfw   input                   ;result += input
skpnc
incf    result+1,f              ;carry
movfw   input+1

clrc                            ;result <<=1;
rlf     result,f
rlf     result+1,f
return

> {Original Message removed}
<117EC968C6D8D211A9520020AF155EB23A8B72@ISERVER> quoted-printable