Hi Andres,

On Thu, Sep 02, 2010 at 09:35:22PM +0200, Andres Vahter wrote:
> horner_mul_int.s43
> 
> ;******************************************************************************
> ;   MSP430FG439 Integer-Integer multiplication using Horner's Algorithm 
> ;
> ;   Description: This code performs a 16-bit integer-integer multplication 
> ;                 of numbers to return an 16-bit integer
> ;                 
> ;
> ;   Note:        This code assumes 32.768kHz XTAL on LFXT1 on the MSP430FG439 
> ;                 MSP430FG439
> ;               -----------------
> ;              |              XIN|-  
> ;              |                 | 32.768kHz
> ;              |             XOUT|-
> ;              |                 |
> ;
> ;
> ;   K. Venkat
> ;   Texas Instruments Inc.
> ;   July 2006
> ;   Built with IAR Embedded Workbench Version: 3.41A
> ;*******************************************************************************/
>             public mul_horner_int
>       
>             RSEG CODE
>         
> mul_horner_int
> 
>             mov.w     R12,R13               ; The operand "input" in register 
> R12 
>             rla.w     R13             
>             add.w     R12,R13               ; X1=X*2^1+X
>             rla.w     R13
>             rla.w     R13
>             add.w     R12,R13               ; X2=X1*2^2+X
>             rla.w     R13
>             add.w     R12,R13               ; X3=X2*2^1+X
>             rla.w     R13
>             add.w     R12,R13               ; X4=X4*2^1+X
>             rla.w     R13
>             rla.w     R13
>             rla.w     R13
>             add.w     R12,R13               ; Final Result=X5=X4*2^3+X 
>             mov.w     R13,R12               ; The final answer returned to 
> the 
>                                             ; calling function
>             ret
>             END

The binary representation of the number 441 is embedded in the code from left 
to right.

441 = 110111001b

Something like the following pseudo-code:

for each binary digit d do:
    if d == 1
        mov.w     R12,R13
        rla.w     R13
    else
        rla.w     R13
end

baruch


-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

Reply via email to