问题描述
限时送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:关键词]
发布评论