显式访问 ARM 上的存储寄存器 [英] Explicitly accessing banked registers on ARM

查看:32
本文介绍了显式访问 ARM 上的存储寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 ARM 手册,应该可以访问特定 CPU 模式的存储寄存器,例如r13_svc".当我尝试执行此操作时,gcc 对我大喊大叫并显示以下错误:

According to the ARM manual, it should be possible to access the banked registers for a specific CPU mode as, for instance, "r13_svc". When I try to do this gcc yells at me with the following error:

立即表达式需要#前缀——`mov r2,sp_svc'

immediate expression requires a # prefix -- `mov r2,sp_svc'

怎么了?

更新.以下来自 ARMv5 和 ARMv6 的 ARM 架构参考手册的文字让我相信这是可能的,第 A2.4.2 节:

Update. The following text from the ARM Architecture Reference Manual for ARMv5 and ARMv6 led me to believe that it is possible, section A2.4.2:

寄存器 R13 和 R14 有六个存储区每个物理寄存器.一个是用在用户和系统模式下,以及每个其余五个用于其中之一五种异常模式.在哪儿需要具体说明哪些版本被引用,你使用表格名称:R13_modeR14_mode 其中 mode 是适当的 usr、svc 之一(对于主管模式)、abt、und、irq 和无误

Registers R13 and R14 have six banked physical registers each. One is used in User and System modes, and each of the remaining five is used in one of the five exception modes. Where it is necessary to be specific about which version is being referred to, you use names of the form: R13_mode R14_mode where mode is the appropriate one of usr, svc (for Supervisor mode), abt, und, irq and fiq.

推荐答案

我认为 mov 指令不可能;至少根据我正在阅读的 ARM 架构参考手册.你有什么文件?ldm 有一个变体,可以从特权模式(使用^)加载用户模式寄存器.您唯一的其他选择是切换到 SVC 模式,执行 mov r2, sp,然后切换回您使用的任何其他模式.

I don't think that's possible with the mov instruction; at least according to the ARM Architecture Reference Manual I'm reading. What document do you have? There are is a variant of ldm that can load user mode registers from a privileged mode (using ^). Your only other option is to switch to SVC mode, do mov r2, sp, and then switch back to whatever other mode you were using.

你得到的错误是因为它不理解 sp_svc,所以它认为你正在尝试立即执行 mov,它看起来像:

The error you're getting is because it doesn't understand sp_svc, so it thinks you're trying to do an immediate mov, which would look like:

mov r2, #0x14

这就是为什么它说需要 # 前缀".

So that's why it says "requires a # prefix".

这篇关于显式访问 ARM 上的存储寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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