【发布时间】:2013-07-04 09:02:25
【问题描述】:
我正在尝试将ARM 寄存器(R0) 指向的数据加载到另一个寄存器(R1)
所以,我正在使用LDR R1,[R0]。
但是R0 是一个立即值,例如
LDR R0,=0x0804c000
我遇到了分段错误。
注册信息
(gdb) info registers
r0 0x804c000 134529024
r1 0x1 1
r2 0x804c044 134529092
r3 0x1 1
r4 0x804c088 134529160
r5 0x0 0
r6 0x804c0cc 134529228
r7 0xbe9746c4 3197585092
r8 0x804c110 134529296
r9 0x8fb9 36793
r10 0x804c154 134529364
r11 0x0 0
r12 0x0 0
sp 0xbe9746c4 0xbe9746c4
lr 0x8939 35129
pc 0x89f0 0x89f0 <test46+48>
cpsr 0x60000030 1610612784
Disassembler:
(gdb) disassemble
Dump of assembler code for function test46:
0x000089c0 <+0>: push {r7}
0x000089c2 <+2>: add r7, sp, #0
0x000089c4 <+4>: ldr r0, [pc, #60] ; (0x8a04)
0x000089c6 <+6>: ldr r2, [pc, #64] ; (0x8a08)
0x000089c8 <+8>: ldr r4, [pc, #64] ; (0x8a0c)
0x000089ca <+10>: ldr r6, [pc, #68] ; (0x8a10)
0x000089cc <+12>: ldr.w r8, [pc, #68] ; 0x8a14
0x000089d0 <+16>: ldr.w r10, [pc, #68] ; 0x8a18
0x000089d4 <+20>: nop
0x000089d6 <+22>: nop
0x000089d8 <+24>: nop
0x000089da <+26>: nop
0x000089dc <+28>: nop
0x000089de <+30>: nop
0x000089e0 <+32>: nop
0x000089e2 <+34>: nop
0x000089e4 <+36>: nop
0x000089e6 <+38>: nop
0x000089e8 <+40>: nop
0x000089ea <+42>: nop
0x000089ec <+44>: nop
0x000089ee <+46>: nop
=> 0x000089f0 <+48>: ldr r1, [r0, #0]
0x000089f2 <+50>: ldr r3, [r2, #0]
0x000089f4 <+52>: ldr r5, [r4, #0]
0x000089f6 <+54>: ldr r7, [r6, #0]
0x000089f8 <+56>: ldr.w r9, [r8]
0x000089fc <+60>: ldr.w r11, [r10]
0x00008a00 <+64>: b.n 0x89f0 <test46+48>
End of assembler dump.
LDR指令不能这样用吗?我可以使用以下命令将数据从 R0 移动到 R1 没有任何问题MOV R1, R0
这是我的compilation flags:
gcc -std=c99 -mthumb -march=armv7 -mthumb-interwork -static -ffunction-sections
【问题讨论】:
-
我没想到你可以直接访问缓存并读取它。你用的是什么处理器?你能指点我的数据表吗?
-
http://www.arndaleboard.org/wiki/index.php/Main_Page -
你想做什么?即,总体目的或目标是什么?你只是在玩汇编程序还是真的在尝试做某事?如果是这样,你能描述一下吗?