0
votes

While writing a code in ARMSIM, I want to label a particular memory location(say) 0x2000 as PATH and use it in the ARM assembly code in MOV, LDR,STR instructions. Please let me know if this is possible.

1
On ARM you use register-indirect addressing for loads and stores. Anyway, if you want to define a compile-time constant, use EQU (or whichever similar directive provided by ARMSIM).Michael
The actual syntax is probably .equ PATH, 0x2000.Jester
Thank you Michael and Jester. But this PATH label does not allow me use STR or LDR instructions with it. For example, STR R9,PATH and LDR R10,PATH to store some value in R9 at 0x2000 and then retrieve it.aravind d
Define "does not allow" ... do you get some error? If so, what exactly? Also note what Michael said ... you must load the address into a register first, as arm does not allow offsets in the range 0x2000.Jester
ARMSIM displays - "Syntax Error, unexpected ident, expecting '[', or '=' " just below the STR R9, PATH line.aravind d

1 Answers

0
votes

You can use this type of method also,

var1 DCD 0x00
var2 DCD 0x00

  LDR R0,=var1    ; Address of var1
  LDR R1,[R0]     ; read var1 in to R1
  LDR R0,=var2    ; base address of MyAsmVar
  LDR R2,[R0]     ; Address of var2

Reference: http://www.keil.com/forum/18423/declaring-variables-in-cortex-m3-assembly-language/