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.

Function Definition from library



Hi

I have a library which contains u_div.obj file.  U_div.obj have the definition of function U$$DIV. U$$DIV function performs unsigned 16 bit division operation.

My requirement is to perform the unsigned 16 bit division operation the function definition should be referred from library as library contains the definition to perform the same.

But it’s not happening. To perform the division operation it is writing its own definition. Refer below snap shot.

  If it is referring the library for function definition I should see the function call to U$$DIV in the assembly code.

 Please suggest solution to fix this issue.  

  • Munaf,

    You have call the function defined in u_lib.obj and pass unsigned_divdend and unsigned_divisor as arguments. You have not done that in your example.

    -Manoj

  • Hi Manoj,

    When performing modulus operation between two variables, I should see the function call to U$$MOD in the assembly code.

    Compiler places an implicit call based on the operands to the modulo operator   ”%”.

    Same is shown in the snap shot below.

    But in case of division operation I am not able to see the function call to U$$DIV in the assembly code.

    As my library contains the definition (u_div.obj) of the division operation I should see the function call in the assembly code. But actually it is not happening. Its writing its own function definition.

  • RPT  #15 || SUBCU is an unsigned integer Division. This parallel instruction takes only 17 cycles, so it is faster then calling a function.

    If you would like to force the complier NOT t use RPT/SUBCU, set the compiler options to disable "RPT". IN this case the compiler will generate the U$$DIV function call, which takes more cycles.