0

我正在尝试从两个不同的寄存器中load获取数据。storearm

int testing[64*1024]  __attribute__ ((aligned (8192)));
__asm__("MOV r0, %0" :: "r" (testing) : "r0");
__asm__("STR R5,[R0];");

在我最初的尝试中,我尝试将寄存器指向的一些数据存储r0到 register r5。绝对没有编译问题,但寄存器中的数据cannot be accessed.

这也是同样的情况Load

LDR R1,[R0]



(gdb) info registers
r0             0xb6000  745472
r1             0x1      1
r2             0x0      0
r3             0xb6000  745472
r4             0x8961   35169
r5             0x0      0
r6             0x0      0
r7             0xbeba9664       3199899236
r8             0x0      0
r9             0xefb9   61369
r10            0xf02d   61485
r11            0x0      0
r12            0x0      0
sp             0xbeba9664       0xbeba9664
lr             0x89cb   35275
pc             0xeace   0xeace <test48+14>
cpsr           0x60000030       1610612784
(gdb) bt
#0  0x0000eace in test48 ()
#1  0x000089ca in main ()
(gdb) x/x $r5
0x0:    Cannot access memory at address 0x0
(gdb) x/x $r0
0xb6000 <testing>: 0x00000000

本质上,我正在尝试使用 ldr 和 str 实现一些内存内联寻址。

我在构建示例时获得了指南的帮助

知道我哪里出错了

4

1 回答 1

3

Your comment and your code do not match:

In my initial attempt I tried to store some data pointed to by the register r0 to register r5 [...] __asm__("STR R5,[R0];");

The instruction you wrote stores the value of R5 into the memory location that R0 points to. The register R5 does not point to any memory location - its value is 0x00 in your example.

The __asm__ statements do not declare the R5 register used in any way, so the compiler is free to put any temporary value or variable in it. This also explains:

(gdb) x/x $r5
0x0:    Cannot access memory at address 0x0

Your gdb command tries to access the memory location that R5 points to - but it does not point at any.

于 2013-07-11T15:26:17.803 回答