Reputation: 2456
I am trying to load
and store
data from two different arm
registers.
int testing[64*1024] __attribute__ ((aligned (8192)));
__asm__("MOV r0, %0" :: "r" (testing) : "r0");
__asm__("STR R5,[R0];");
In my initial attempt I tried to store some data pointed to by the register r0
to register r5
. There are absolutely no compilation problems but the data in the register cannot be accessed.
It is the same case for Load
as well.
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
Essentially I am trying to achieve some memory inline addressing using ldr and str.
I took help of this guide while I was building my example
Any idea where I am going wrong
Upvotes: 0
Views: 3086
Reputation: 7691
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.
Upvotes: 3