armv7:stmb 不占用 pc
我有一个用 C 语言编写的库,与一些 ARM 程序集混合在一起。它曾经是为armv6编译的。现在我正在尝试将其升级到armv7。然而,有一个中断处理程序包含指令 stmdb sp!, {pc}
,这在armv7中是不允许的。 armv7 上的等效指令是什么?我尝试了 str r15, [sp, #-4]!
但这不起作用。
I have a library written in C mixed mixed with some assembly for ARM. It used to be compiled for armv6. Now I am trying to upgrade it to armv7. However, there is an interrupt handler which has the instruction stmdb sp!, {pc}
which is not allowed in armv7. What would be an equivalent instruction on armv7? I tried str r15, [sp, #-4]!
but that doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PUSH
和POP
指令的寄存器列表中使用PC
有具体限制,具体取决于操作模式,请参见:ARM指令集参考,
PUSH
/POP
具体来说,在 Thumb[2] 中,没有
push {pc}
操作(这相当于没有stmfd sp!, {pc}
操作 -push
映射到stmfd sp!
)。因此,如果您正在编译内核代码(如果不是内核代码,为什么您拥有/需要中断处理程序),请检查您是否正在编译 Thumb-2 内核。
也就是说,您是说您遇到了
stmfd sp!,{pc}
指令 - 您确定这不是拼写错误?stmfd sp!,{lr}
(及其同级,ldmfd sp!, {pc}
- 这里存在PC
)正常/完全合法且在 ARM 模式和 Thumb-2 模式下经常需要/遇到。但这实际上就是将程序计数器保存到堆栈的目的吗?人们可以用其他方法无法实现的事情来做什么呢?There's specific limitations regarding the use of
PC
in the reg list forPUSH
andPOP
instructions, depending on the operation mode, see:ARM Instruction Set Reference,
PUSH
/POP
Specifically, in Thumb[2] there is no
push {pc}
operation (which is the same as saying there's nostmfd sp!, {pc}
operation -push
is mapped tostmfd sp!
).So if you're compiling your kernel code (why else do you have/need an interrupt handler if it's not kernel code), check whether you're compiling a Thumb-2 kernel.
That said, you're saying you encountered a
stmfd sp!,{pc}
instruction - you're sure that's not a typo ?stmfd sp!,{lr}
(and its sibling,ldmfd sp!, {pc}
- herePC
is present) is normal / fully legal and often required / encountered in both ARM mode and Thumb-2 mode. But that actually is the purpose of saving the program counter to the stack ? What can one do with that that wouldn't be achievable in other ways ?“armv7”相当通用。你用的实际芯片是什么?您正在为 ARMv7-M 进行编译吗?然后尝试
PUSH {PC}
。但我预计这不会是您遇到的唯一问题。我认为您应该发布一些片段并更详细地描述您要移植到的特定环境。"armv7" is rather generic. What's the actual chip you're using? Are you compiling for ARMv7-M? Try
PUSH {PC}
then. Though I expect that won't be the only issue you will run into. I think you should post some snippets and describe in more details what specific environment you're porting to.