This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Code for integer division on Cortex-A8?

Hi all,

when I wrote a C code with division operation the compiler is generating some library calls.....when I tried to see the equivalent code for those function calls...I'm unable to reach there (may be because they arm library SW routines)...I cant use those SW routine calls...I can embed the equivalent code in my program( in assembly code). Form where I can get the Equivalent codes for division SW routines....I need codes for 32-bit/32-bit ,32-bit/16-bit & 16-bit/16-bit divisions....

Thanks in advance....

Parents
  • It isn't always quite as simple as that. Sometimes there's an extra instruction as depending on the constant the last bit may need extra twiddling. It's not something one can or should do by hand, plagiarizing the output of the compiler is best. In fact I just think of C as my assembler language and would only touch actual assembler in extreme circumstances.

Reply
  • It isn't always quite as simple as that. Sometimes there's an extra instruction as depending on the constant the last bit may need extra twiddling. It's not something one can or should do by hand, plagiarizing the output of the compiler is best. In fact I just think of C as my assembler language and would only touch actual assembler in extreme circumstances.

Children
  • Hi Daith,

    Thanks for your reply. I agree that it isn't always that simple. Many don't realise, for instance, that ASR doesn't exactly replace integer division because it doesn't round properly. But, as you say, this isn't something which you should undertake unless you really know what you're doing.

    We might debate your comment about using the C compiler as an "assembler" another time. I have quite strong views on that! C is relatively "low-level" when compared with other high-level languages but I think it's wrong to thing of it as an assembly replacement. If you're trying to write assembly code, then my view is that you should use an assembler!

    Chris

  • Chris Shore wrote:

     

    Thanks for your reply. I agree that it isn't always that simple. Many don't realise, for instance, that ASR doesn't exactly replace integer division because it doesn't round properly.

    Though to be honest I think floored division is superior to truncated division, especially with regard to the associated mod operator. But yes, the difference is something to be aware of.