如何在ARM GCC内联汇编中将单个寄存器指定为约束? [英] How to specify an individual register as constraint in ARM GCC inline assembly?

查看:301
本文介绍了如何在ARM GCC内联汇编中将单个寄存器指定为约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在x86内联汇编中,我可以这样写:

in x86 inline assembly i can write something like this:

asm ("cpuid"
            : "=a" (_eax),
              "=b" (_ebx),
              "=c" (_ecx),
              "=d" (_edx)
            : "a" (op));

所以在matchin约束中,而不是只写"= r"并让编译器选择了寄存器,我可以说我想使用哪个特定的寄存器(例如,使用%eax的= a)

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/zh/documents/arm-inline-asm.html 指出,例如,我可以使用约束 通用寄存器R0-R15之一的"r" VFP浮点寄存器S0-S31之一的"w"

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?

推荐答案

我认为ARM的gcc不允许您使用显式寄存器变量指定用于在其中存储变量的寄存器:

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屋!

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