Syntax for an immediate offset value from an assembly time calculation

I would like to calculate an offset from the current PC to a label in subsequent program flow.

E.g.

        instruction to use #value

        value = label - .

label: other instruction

How would be the syntax for that?

Parents
  •      .org 0x20000000
          str r0,[r15,here-.]
    branch: b here
    
    here:   .dc.l 0xffffffff
    there:  .dc.l 23568900
          .end
    

    The above is incorrect of course, just to show my intention. I want to construct

    an instruction to store something PC-relative (R15) and from my understanding this works when an offset is specified.

    The offset has to be an immediate value. (starting with #). The assembler knows the value (here - . ). What would be the correct syntax for this?

    I get:

    $ make
    arm-none-eabi-as l.s
    l.s: Assembler messages:
    l.s:2: Error: immediate expression requires a # prefix -- `str r0,[r15,here-.]'
    make: *** [l.o] Error 1

Reply
  •      .org 0x20000000
          str r0,[r15,here-.]
    branch: b here
    
    here:   .dc.l 0xffffffff
    there:  .dc.l 23568900
          .end
    

    The above is incorrect of course, just to show my intention. I want to construct

    an instruction to store something PC-relative (R15) and from my understanding this works when an offset is specified.

    The offset has to be an immediate value. (starting with #). The assembler knows the value (here - . ). What would be the correct syntax for this?

    I get:

    $ make
    arm-none-eabi-as l.s
    l.s: Assembler messages:
    l.s:2: Error: immediate expression requires a # prefix -- `str r0,[r15,here-.]'
    make: *** [l.o] Error 1

Children
More questions in this forum