如何在 ARM 上进行整数(有符号或无符号)除法? [英] How does one do integer (signed or unsigned) division on ARM?

查看:34
本文介绍了如何在 ARM 上进行整数(有符号或无符号)除法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究 Cortex-A8 和 Cortex-A9.我知道有些架构没有整数除法,但是除了转换为浮点数、除法、转换为整数之外,最好的方法是什么?或者这确实是最好的解决方案?

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 to float, divide, convert to integer? Or is that indeed the best solution?

干杯!=)

推荐答案

编译器通常在其库中包含一个除法,例如 gcclib 我从 gcc 中提取它们并直接使用它们:

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/ 然后是 stm32f4d/adventure/gcclib

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/ 然后是 stm32f4d/float01/vectors.

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

我没有计时,看看有多快/多慢.明白我在上面使用 cortex-m 而你在谈论 cortex-a,光谱的不同端,类似的浮点指令和 gcc lib 的东西是相似的,对于 cortex-m,我必须为拇指构建,但你可以就像为手臂轻松打造一样.实际上使用 gcc 它应该只是自动工作,你不应该像我那样做.其他编译器以及您不应该像我在上面的冒险游戏中那样做.

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.

这篇关于如何在 ARM 上进行整数(有符号或无符号)除法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆