|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:
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.
Request the files attached to this knowledgebase article.
Article last edited on: 2010-07-14 08:12:07
Did you find this article helpful? Yes No
How can we improve this article?