How do I declare a variable in ARM inline Assembly?
And how do I move the value from register to variable and vice versa?
Looking for something like this,
__asm(
variable: Word #22222222
mov r0, variable
mov variable, r0
)
if you're using inline assembler in a C or C++ program, you should just define the variable in the C part of the code: static uint32_t variable = 0x22222222;For a separate module using the gnu assembler, data and program space get relocated at link time as appropriate for the chip, so you have to explicitly tell the assembler which "section" to put things in using ".data", ".text", or ".section" directives. It would look something like:
.data variable: .long 0x22222222 // global variable .text myfunc: ldr r1, =variable ;; get addr of variable from pc-relative constant ldr r2, [r1] ;; get the actual value of variable str r2, [r1] ;; store it back.