Hi im trying to call a assembler subroutine from c and get this error. On the Arm websites, there is just stated that this error exists.. C Code
#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);
}
Assembler Code
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
FINAL SOLUTION WHICH WORKS
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
CodePudding user response:
You use the wrong instruction. LDR - Load with immediate offset, pre-indexed immediate offset, or post-indexed immediate offset
You need to use mov instruction
