Referencing Labels

You can give reference to the contents of a label and the address of a label in ARM Assemblers.

The equal sign (=) distinguishes between the address of a label reference and the contents of a label reference.

ldr r1, label // Returns the contents of the label.

ldr r1, =label // Returns the actual address of the label.

The following listing shows the code using label and =label.

Listing: Referencing Labels Using label and =label
main.c

extern void asmfunc(void;

int main()

{

   asmfunc();

}

asmfunc.asm

   .public asmfunc

   .public__SP_INIT

SVC_Stack_Size .equ 0x100

   .text

asmfunc:

   ldr r1,=@SVC_Stack

   ldr r0,=@USR_Stack

   ldr r1,@SVC_Stack

   ldr r0,@USR_Stack

   ldr r2,[r1]

   ldr r3,[r0]

   mov pc,lr

@SVC_Stack

   .long__SP_INIT

@USR_Stack

   .long__SP_INIT-SVC_Stack_Size