ARM Technical Support Knowledge Articles


Applies to: C51 C Compiler


Information in this knowledgebase article applies to:


I have an algorithm that depends on the execution speed of integer division. I am using a device without an arithmetic unit. Therefore, I cannot use an algorithm that relies on an arithmetic unit.

The algorithm that I need to speed up has the following requirements:

I have investigated the algorithm provided in the C51 Compiler Run-Time Library. It appears to be quite clever. But, is there a way to speed it up even further?


Yes. When it is possible to constrain the values used in math operations (like division) so that they fall within a specific range, you can create an algorithm that is faster than the standard division algorithm. In addition, loops in the division algorithm can be unrolled to gain a little more speed (at the cost of wasting memory).

The attachment to this knowledgebase article presents two solutions to your problem:

  1. An optimized library function that improves execution speed of division by about 23%. This function works for all value ranges and may be used instead of the C51 Run-Time Library function. To use this function, just add the module UIDIV_F.A51 to your project.
  2. A dedicated function that improves execution speed of division by about 37%. This function is defined as follows:
    unsigned int divu12u8 (unsigned int v, unsigned char d);
    To use this function you must modify your application code so that it calls the divu12u8 function rather than the standard division operation (using the / operator). Note that this routine does not yield correct results when v exceeds the value 4095. Therefore, you must be certain that your values are within a specific range.

    To use this division routine add the module DIVU12U8.A51 to your application. Enable Register Coloring under Projects - Options for Target - C51 to further optimize the register usage of your application.




Request the files attached to this knowledgebase article.

Article last edited on: 2010-07-14 08:12:07

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential