【问题标题】:What does "A1114E: Expected register relative expression" mean?“A1114E:预期的寄存器相对表达式”是什么意思?
【发布时间】:2021-11-26 11:42:15
【问题描述】:

嗨,我试图从 c 调用汇编程序子例程并得到这个错误。在 Arm 网站上,刚刚声明存在此错误。 C代码

    #include <stdint.h>
extern void out_word(uint32_t out_address, uint32_t out_value);
extern uint32_t in_word(uint32_t in_address);
int main(void){
        uint32_t value = in_word(0x60000200);
        uint32_t address = 0x60000100;
        out_word(address,value);
    return (0);
}

汇编代码

                PRESERVE8
                AREA myCode, CODE, READONLY
                EXPORT in_word
                EXPORT out_word

in_word         PUSH {R1-R7}
                LDR R1, R0 ; line which produces the problem
                LDR R0, [R1]
                POP {R1-R7}
                BX LR
                
                
out_word        STR R1, [R0]
                BX LR
                   
                END

【问题讨论】:

  • LD 是一个从内存加载指令。要在寄存器之间复制,您需要使用(可能命名错误)move 指令MOV
  • R0 不是内存寻址模式。你在下一行的[R1] 是。如果你愿意,你知道你可以ldr r0, [r0],对吧? IDK 为什么你要推送/弹出这么多寄存器。
  • @PeterCordes 我也不知道,我现在删除了它,它仍然有效。谢谢
  • 如果您想发布您的工作代码,请发布实际的答案,而不是对问题的编辑。回答您自己的问题是 100% 没问题的,只要它是作为实际答案编写的。

标签: assembly arm addressing-mode


【解决方案1】:

您使用了错误的指令。 LDR - 使用立即偏移、预索引立即偏移或后索引立即偏移加载

你需要使用mov指令

【讨论】:

  • 谢谢,成功了
【解决方案2】:

有效的最终解决方案

                PRESERVE8
                AREA myCode, CODE, READONLY
                EXPORT in_word
                EXPORT out_word

in_word         LDR R0, [R0]
                BX LR
                
                
out_word        STR R1, [R0]
                BX LR
                   
                END

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 2013-10-02
    相关资源
    最近更新 更多