This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 horner method for divide and multiply operation

Other Parts Discussed in Thread: CSD

Hello Champs!

I got the information for more efficient calculation of multiplication and division which called Horner and Horner+CSD method from SLAA329 document.
Here's the link.
http://www.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa329&docCategoryId=1&familyId=342
http://www.ti.com/lit/an/slaa329/slaa329.pdf
http://www.ti.com/litv/zip/slaa329

What I want to know of these source code is as below.

  • In case of div_int.c they just use one parameter in the horner function.
    ie) result3 = div_horner_int(input)
  • I think two parameters should be needed in the parameter(input and divisor), but there's no documents represented this in the web site. 
  • And I tested with changing input and divisor value, but the result show wrong value.

  • So if you have any modified functions(Horner, Horner+CSD) regarding slaa329 document, please let me know.
Thank you.

------------------------------------------------

cf) Here's the test source code in slaa329

#include <stdio.h>
#include <msp430xG43x.h>
int div_c_int(int,int);
int div_horner_int(register int);
int div_csd_int(register int);
int div_hamacher(register int, register int);
int input=9280;         // If we change this variable, some result show wrong answer.
int divisor=41;          //  If we change this variable, some result show wrong answer.
int result1,result2,result3,result4;

int div_c(int x, int y) // C routine for division
{
return(x/y);
}

main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT.
FLL_CTL0 |= XCAP18PF; // Configure load caps.
result1=div_c(input,divisor); // C routine called for division

result2=div_hamacher(input,divisor);
result3=div_horner_int(input);                // I think this code should have two parameters for calculating divide operation.
result4=div_csd_int(input);                     // I think this code should have two parameters for calculating divide operation.

__no_operation(); // for breakpoint
while(1);
}

  • The Horner method requires that the divisior is known in advance. This is stated in both the Abstract  and at Horner's method in SLAA329:

    "Note that Horner's method requires the multiplier or the divisor to be known in advance to function..."

    Horner's method does division by a constant. In order to divide by a variable, another method is required (here div_hamacher() is provided for that purpose)

    Because of that, it is natural that div_horner_int() and div_csd_int() only have one input argument.

  • Ernest Cho said:
    result3=div_horner_int(input);                // I think this code should have two parameters for calculating divide operation.

    You shall read slaa329 carefully because it states:

    The Horner’s method requires the multiplier or the divisor to be known in advance. This is not a serious
    limitation, since few applications perform multiplication or division of numbers that change at runtime.
    Once this is established, the multiplication or division can be performed efficiently with just shift and add
    operations. The operand is denoted by X, the multiplier by M, and the divisor by D.

    Ernest Cho said:
    int input=9280;         // If we change this variable, some result show wrong answer.
    int divisor=41;          //  If we change this variable, some result show wrong answer.

    Subroutines are hardcoded. Divisor is encoded in the code, not passed as parameter. Subroutine div_horner_int() of file div_horner_int.s43 can't do any other division than divide by 41.

**Attention** This is a public forum