[英]error: unknown mnemonic in armv8 when compiling with gcc
I am trying to compile a project with multiple c files and an assembly file written in ARMv8, which I have not done before, so I am having some trouble understanding a few error messages I am getting.我正在尝试编译一个包含多个 c 文件和一个用 ARMv8 编写的汇编文件的项目,这是我以前没有做过的,所以我在理解我收到的一些错误消息时遇到了一些麻烦。
I consistently receive the "unknown mnemonic" error throughout, for almost every single line.对于几乎每一行,我始终收到“未知助记符”错误。 For example, for the following snippet of code,
例如,对于以下代码片段,
100 ## Save oSum to the stack.
101 pushq %rdx
102
103 ## unsigned long ulCarry
104 subq $8, %rsp
105
106 ## unsigned long ulSum
107 subq $8, %rsp
108
109 ## long lIndex
110 subq $8, %rsp
111
112 ## long lSumLength
113 subq $8, %rsp
I receive the following messages,我收到以下消息,
file.s:101: Error: unknown mnemonic `pushq' -- `pushq %rdx'
file.s:104: Error: unknown mnemonic `subq' -- `subq $8,%rsp'
file.s:107: Error: unknown mnemonic `subq' -- `subq $8,%rsp'
file.s:110: Error: unknown mnemonic `subq' -- `subq $8,%rsp'
file.s:113: Error: unknown mnemonic `subq' -- `subq $8,%rsp'
What I am I doing wrong here?我在这里做错了什么? How can I fix this?
我怎样才能解决这个问题?
Your help is much appreciated.非常感谢您的帮助。
Problem is actually really simple, what you were typing was 64-bit x86 Assembly, not ARM. The code you've written does have an equivalent in ARM Assembly, but the register names and instruction names will be different.问题实际上很简单,您输入的是 64 位 x86 程序集,而不是 ARM。您编写的代码在 ARM 程序集中确实具有等效项,但寄存器名称和指令名称会有所不同。 I believe armv8 is a 32-bit architecture (there's a 64-bit version, commonly called AArch64 or arm64.) I'm not familiar with that unfortunately.
我相信 armv8 是一个 32 位架构(有一个 64 位版本,通常称为 AArch64 或 arm64。)不幸的是我对此并不熟悉。 Try this:
试试这个:
push {r4,r5,r6,lr} //ARM calling convention requires an even number of regs to be pushed
sub sp,sp,32
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.