ARM指令SWI和SVC完全相同吗?
ARM 汇编语言具有用于进入“管理程序模式”的 SWI 和 SVC 指令。
让我困惑的是,为什么有两个? 这里据说SVC的前身是SWI 。这是否意味着他们基本上改变了助记符?它们是同一件事吗?我可以互换使用它们吗?其中一个是否存在于架构之前,而另一个则存在于架构之后?
ARM assembly has SWI and SVC instructions for entering into 'supervisor mode'.
What confuses me is, why there are two of them? Here it is said that SVC was formerly SWI. Does it mean that basically they changed the mnemonic? Are they the same thing? Can I use them interchangeably? Does one of them exist before an architecture, and other after?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,
SWI
和SVC
是同一件事,只是名称改变了。以前,SVC
指令称为SWI
,即软件中断。SVC
(和SWI
)的操作码部分是用户定义的(位 0-23 是用户定义的,就像 SVC 处理程序的参数)。位 24-27 是b1111
,这 4 位使 CPU 意识到操作码是SVC
(或SWI
)。请参阅 ARM 信息中心 了解更多详情。
Yes,
SWI
andSVC
are same thing, it is just a name change. Previously, theSVC
instruction was calledSWI
, Software Interrupt.The opcode for
SVC
(andSWI
) is partially user defined (bits 0-23 are user defined and are like a parameter to the SVC handler). Bits 24-27 areb1111
and these 4 bits make the CPU realize that the opcode isSVC
(orSWI
).see ARM Information Center for more details.
有一个很好的UAL(统一汇编器)语法) 与 ARMv8 附录 K6 《AArch32 指令集的传统指令语法》
条目之一该表的内容是:
明确指出它们是等效的。
在 GNU GAS 上,您可以使用
.syntax Unified
选择 UAL 语法。在 GCC 中,您可以使用选项
-masm-syntax-unified
进行内联汇编,尽管由于当时修复的错误,它在 8.2.0 中不起作用:如何编写.syntax统一UAL GCC 中的 ARMv7 内联汇编?除了某些指令的名称之外,UAL 与 pre-UAL 还具有进一步的含义,例如,在某些整数文字中是否需要
#
:是ARM 汇编中立即值所需的哈希值?There is a good UAL (Unified Assembler Syntax) vs pre-UAL mnemonic table on ARMv8 Appendix K6 "Legacy Instruction Syntax for AArch32 Instruction Sets"
One of the entries of that table is:
which explicitly states that they are equivalent.
On GNU GAS, you can select the UAL syntax with
.syntax unified
.From GCC, you can use the option
-masm-syntax-unified
for inline assembly, although it wasn't working in 8.2.0 due to a then fixed bug: How to write .syntax unified UAL ARMv7 inline assembly in GCC?UAL vs pre-UAL also has further implications besides the names of certain instructions, e.g. the requirement for
#
or not in certain integer literals: Is the hash required for immediate values in ARM assembly?