问题描述
.Syntax unified
.cpu cortex-m3
.thumb
@ ...
ldr r1,=0x40010800
ldr r0,[r1]
ldr r2,=0x44044444
and r0,r2
orr r0,#0x200000
str r0,[r1]
@ ...
我正在通过gdb和openocd进行调试。
如果我进入and r0,r2
语句并输入下一步,该程序将停止,并显示以下内容:
19 and r0,r2
(gdb) next
halted: PC: 0x080000fe
halted: PC: 0x080000fe
halted: PC: 0x080000fe
...
我不确定为什么这行不通,因为我看不到指令有什么问题;所以我想知道可能是什么问题。
**编辑**(最小的可复制示例):
.Syntax unified
.cpu cortex-m3
.thumb
.word 0x20000400
.word 0x080000ed
.space 0xe4
@ activate clock for GPIOa (interestingly removing this section solves the problem)
ldr r0,=0x40021018
ldr r1,[r0]
orr r1,#0x4
str r0,[r1]
@ configure PA5 as 2 MHz push-pull Output
ldr r1,=0x40010800
ldr r2,=0x44044444
ldr r0,[r1]
and r0,r2
ldr r2,=0x44244444
orr r0,r2
str r0,[r1]
b .
二进制文件构建
$ arm-none-eabi-as -g prog.S -o prog.o
$ arm-none-eabi-ld prog.o -o prog.elf -Ttext=0x08000000
使用以下命令进行调试:
$ openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg
$ arm-none-eabi-gdb prog.elf
(gdb) target remote :3333
(gdb) monitor reset halt
(gdb) stepi
...
使用的Mikrocontroller是 STM32F103RB 。
尽管调试器发出蜂鸣声,但程序仍能正常运行(在和指令的第二个 stepi 之后,LED变成了一个)。
反汇编(x/ni $pc
):
=> 0x80000ec <_stack+133693676>: movs r0,#4
0x80000ee <_stack+133693678>: ldr r1,[pc,#16] ; (0x8000100 <_stack+133693696>)
0x80000f0 <_stack+133693680>: str r0,[r1,#0]
0x80000f2 <_stack+133693682>: ldr r0,#16] ; (0x8000104 <_stack+133693700>)
0x80000f4 <_stack+133693684>: ldr r1,#16] ; (0x8000108 <_stack+133693704>)
0x80000f6 <_stack+133693686>: str r0,#0]
0x80000f8 <_stack+133693688>: movs r0,#32
0x80000fa <_stack+133693690>: ldr r1,#16] ; (0x800010c <_stack+133693708>)
0x80000fc <_stack+133693692>: str r0,#0]
0x80000fe <_stack+133693694>: b.n 0x80000fe <_stack+133693694>
0x8000100 <_stack+133693696>: asrs r0,r3,#32
0x8000102 <_stack+133693698>: ands r2,r0
0x8000104 <_stack+133693700>: add r4,r8
0x8000106 <_stack+133693702>: add r4,r4
0x8000108 <_stack+133693704>: lsrs r0,r0,#32
0x800010a <_stack+133693706>: ands r1,r0
0x800010c <_stack+133693708>: lsrs r4,r1,#32
0x800010e <_stack+133693710>: ands r1,r0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)