How does one do integer (signed or unsigned) division on ARM?

后端 未结 5 1849
长发绾君心
长发绾君心 2020-12-06 00:33

I\'m working on Cortex-A8 and Cortex-A9 in particular. I know that some architectures don\'t come with integer division, but what is the best way to do it other than convert

5条回答
  •  旧巷少年郎
    2020-12-06 01:17

    The compiler normally includes a divide in its library, gcclib for example I have extracted them from gcc and use them directly:

    https://github.com/dwelch67/stm32vld/ then stm32f4d/adventure/gcclib

    going to float and back is probably not the best solution. you can try it and see how fast it is...This is a multiply but could as easily make it a divide:

    https://github.com/dwelch67/stm32vld/ then stm32f4d/float01/vectors.s

    I didnt time it though to see how fast/slow. Understood I am using a cortex-m above and you are talking about a cortex-a, different ends of the spectrum, similar float instructions and the gcc lib stuff is similar, for the cortex-m I have to build for thumb but you can just as easily build for arm. Actually with gcc it should all just work automagically you should not need to do it the way I did it. Other compilers as well you should not need to do it the way I did it in the adventure game above.

提交回复
热议问题