【问题标题】:Code execution in Stack in Cortex-M4Cortex-M4 堆栈中的代码执行
【发布时间】:2015-03-29 12:27:18
【问题描述】:

我正在尝试将代码从代码内存复制到堆栈,然后在堆栈中使用该代码执行。我正在使用以下功能

;Personal Function
IMPORT extfunc
EXPORT func
func
LDR R0,=extfunc;Function  in C 
LDR R1,=0x00000000;Counter for Counting instructions when i make code generic
PUSH {LR};For nested call       
ADD R3,SP,#0x00;move 
SUB SP,#0x10;As stack grows upwards, we just make space for 10 instructions for testing
ADD R5,SP,#0x0;Where we branch after copying
LOOP
LDR SP,[R0];Load in stack instruction
ADD R1,R1,#0x01;instruction count
ADD R0,#0x04;next C instruction address 
ADD SP,#0x04;next instruction address
CMP R1,#0x10;Copy 10 instructions
BLT LOOP
ADD R0,PC,#0x0C;Get ready for branching
ADD LR,R0,#0x00;LR prepared
ADD PC,R5,#0x00;GO
ADD SP,R3,#0x00;When we return restore the SP
POP {LR}
BX LR

但我收到以下错误

startup_XMC4500.s(335):错误:A1477E:此寄存器组合导致不可预测的行为

startup_XMC4500.s(336):错误:A1477E:此寄存器组合导致不可预测的行为

显然您无法将 PC 移动到运行时计算的任意地址,谁能告诉我解决此问题的方法?

【问题讨论】:

    标签: assembly stack arm runtime


    【解决方案1】:

    事实证明,您无法通过添加具有某些值的寄存器并将它们存储回来来操作特殊寄存器,您必须使用显式加载或存储指令..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-23
      • 2018-09-29
      • 2015-03-12
      • 2016-01-28
      • 2016-05-01
      • 2015-02-24
      • 2020-03-22
      • 1970-01-01
      相关资源
      最近更新 更多