我有一个非常奇怪的错误,ldr指令首先将一个有效值加载到R3寄存器中,然后当我使用调试器跨过一条指令时,它突然包含了0x0值。
此程序集由GCC9 for C++17从GCC9生成。
这些指示是:
ldr r3, [r7, #12] ; after this instruction r3 will have value 0x20009da0
ldr r3, [r3, #8] ; after this instruction r3 will have value 0x20003e28
ldr r3, [r3] ; after this instruction r3 will have value 0x00020a2c, the value at this addr is 0000a1a9
ldr r3, [r3] ; after this instruction r3 will suddenly have value 0x00000000
ldr r2, [r7, #12]
ldr r2, [r2, #8]
mov r0, r2
blx r3 ; at this point r3 still has value 0x00000000 causing the reset handler to be calledr3不应该在上一次ldr指令之后有值0x0000a1a9吗?
为了提供更多的信息,我正在用安装了ATSAMD51J20A的Microchip开发微芯片的GCC9。发生这种情况的代码是:
auto& socket = m_device.get_socket();其中,get_socket()的返回值是对接口类的引用,而get_socket()的实际实现则返回对扩展该接口的类的引用。
发布于 2022-05-31 01:14:40
我记得微芯片编译器有奇怪的(时间?)重复指令行以意想不到的方式运行的问题。我仍然不知道细节,但有时在这些行之间填充NOPs可以解决问题。
https://stackoverflow.com/questions/71767709
复制相似问题