ARM汇编,无乘以MUL指令 [英] ARM assembly, multiplying without MUL instruction
本文介绍了ARM汇编,无乘以MUL指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经广泛研究这一点,并没有发现任何答案。我需要乘以* 17,而不需要使用ARM汇编语言乘法指令。我知道你可以使用RSB,但如何设置的值,或使用LSL#部分是混淆了我。任何帮助将是伟大的!
I have researched this extensively, and have not found any answers. I need to multiply a*17 without using the multiply instructions in ARM assembly language. I understand you can use RSB, but how to set up the values or use the LSL# part is confusing to me. Any help would be great!!
推荐答案
我同意的意见,而只是一个快速提示,编译器一般都在通过优化的常量乘法真的很好。
I agree with comments but just a quick tip, compilers are generally really good at optimizing multiplications by constants.
所以,你可以使用 ARM - * - * - 海湾合作委员会
工具链得到这样的答案
So you can just use an arm-*-*-gcc
toolchain to get this kind of answers.
$ cat m17.c
int f(int i) {
return i * 17;
}
$ arm-linux-gnueabihf-gcc -O3 -S m17.c
$ cat m17.s
<skipped>
f:
add r0, r0, r0, lsl #4
bx lr
<skipped>
和一个可怕的玩笑:使用工具,卢克的
这篇关于ARM汇编,无乘以MUL指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文