armv7:stmb 不占用 pc

发布于 2024-12-11 18:56:41 字数 193 浏览 0 评论 0原文

我有一个用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

邮友 2024-12-18 18:56:41

PUSHPOP 指令的寄存器列表中使用 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 for PUSH and POP 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 no stmfd sp!, {pc} operation - push is mapped to stmfd 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} - here PC 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 ?

但可醉心 2024-12-18 18:56:41

“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文