如何在 ARM GCC 内联汇编中指定单个寄存器作为约束? [英] How to specify an individual register as constraint in ARM GCC inline assembly?
问题描述
在 x86 内联汇编中我可以这样写:
in x86 inline assembly i can write something like this:
asm ("cpuid"
: "=a" (_eax),
"=b" (_ebx),
"=c" (_ecx),
"=d" (_edx)
: "a" (op));
所以在匹配约束中,而不是仅仅写=r"并让编译器选择寄存器,我可以说我想使用哪个特定的寄存器(=a 例如使用 %eax)
so in the matchin constraints instead of just writing "=r" and let the compiler chose the register, I can say which particular register i want to use (=a for example to use %eax)
我怎样才能为 ARM 组装做到这一点?ARM GCC 组装手册 http://www.ethernut.de/en/documents/arm-inline-asm.html 声明我可以使用约束r"表示通用寄存器 R0-R15 之一"w" 表示 VFP 浮点寄存器 S0-S31 之一
how can I do this for ARM assembly? the ARM GCC assembly cookbook http://www.ethernut.de/en/documents/arm-inline-asm.html states that i can for example use the constraints "r" for one of the general purpose registers R0-R15 "w" for one of the VFP floating point registers S0-S31
但是我怎样才能将一个操作数例如精确地限制为 s1?还是特定的通用寄存器?
but how can I constraint an operand for example exactly to s1? or to a particular general purpose register?
推荐答案
我不认为 gcc for ARM 允许你使用 constraints 以准确指定要使用的寄存器.但是,您可以使用 显式寄存器变量 指定一个寄存器来存储变量:
I don't think gcc for ARM allows you to use constraints to specify exactly which register to use. However, you can use explicit register variables to specify a register to store a variable in:
register int my_variable asm("r0");
这篇关于如何在 ARM GCC 内联汇编中指定单个寄存器作为约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!