ARM7TDMI 不支持请求的特殊用途寄存器

编程入门 行业动态 更新时间:2024-10-18 03:37:44
本文介绍了ARM7TDMI 不支持请求的特殊用途寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要将一些使用 ARMASM 编译的代码转换为 gcc(代码源 GCC-4.6.2 eabi).我使用 ARM7TDMI,我的编译参数是

I need to convert some code compiled with ARMASM to gcc(code sourcery GCC-4.6.2 eabi). I use a ARM7TDMI and my compilations arguments are

arm-none-eabi-gcc -c -march=armv4t -mcpu=arm7tdmi -mlittle-endian -g -O1 

(我省略了 -I 和 -D 参数...)

(I omitted the -I and -D arguments...)

在我的一个文件中,我有这段无法编译的代码:

In one of my files I have this code that won't compile :

extern inline void ngEnable( void)
{
    int tmp;
    asm volatile(
        "msr %[tmp], CPSR\n\t"
        "bic %[tmp], %[tmp], #0xC0\n\t"
        "msr CPSR_c, %[tmp]"
        : [tmp] "+r" (tmp)
    );
}

我收到此错误:

C:\DOCUME~1\MALLAR~1.ISC\LOCALS~1\Temp\ccA9cCgQ.s: Assembler messages:
C:\DOCUME~1\MALLAR~1.ISC\LOCALS~1\Temp\ccA9cCgQ.s:267: Error: selected processor does not support requested special purpose register -- `msr r3,CPSR'
make: *** [cdbini.o] Error 1

根据这篇文章 Re:构建 linux-linaro-3.0-2011.08 时遇到的麻烦0(我在 Windows 上构建,但问题可能是一样的?)我已经在使用不使用 -march=all 的解决方法...

according to this post Re: trouble building linux-linaro-3.0-2011.08-0 (I build on windows, but the problem could be the same?) I'm already using the workaround of not using -march=all...

知道我的问题是什么吗?

Any idea of what my problem is?

推荐答案

要读取特殊用途的寄存器,您应该使用 mrs 指令:

To read a special purpose register, you should use the mrs instruction:

extern inline void ngEnable(void)
{
  int tmp;
  asm volatile(
    "mrs %[tmp], CPSR\n\t"
    "bic %[tmp], %[tmp], #0xC0\n\t"
    "msr CPSR_c, %[tmp]"
    : [tmp] "=r" (tmp)
  );
}

在此修复后,代码对我来说很好用.

After this fix, the code works for me just fine.

另外,由于您不使用 tmp 的值,而且您实际上甚至没有设置它,您应该使用 =r (仅输出)而不是 +r(输入-输出).

Also, since you don't use the value of tmp, and you don't in fact even set it, you should use =r (output only) instead of +r (input-output).

这篇关于ARM7TDMI 不支持请求的特殊用途寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-16 14:30:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/889153.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:寄存器   不支持   用途   ARM7TDMI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!