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?
By further reading in the as.pdf manual in the gnu-toolchain documentation I found in chapter 9.4.2.1 that there is a
.syntax directive. Setting it to `unified` gives the desired result. It allows for ommitting the # designator for immediate operands. Although it would be interesting to know how the syntax would look with the "normal" syntax, I can live with that for now:
.syntax unified .org 0x20000000 str r0,[r15,here-.] branch: b here here: .dc.l 0xffffffff there: .dc.l 23568900 .end
and assembled:
arm-none-eabi-as -a l.s ARM GAS l.s page 1 1 .syntax unified 2 0000 00000000 .org 0x20000000 2 00000000 2 00000000 2 00000000 2 00000000 3 20000000 08008FE5 str r0,[r15,here-.] 4 20000004 FFFFFFEA branch: b here 5 6 20000008 FFFFFFFF here: .dc.l 0xffffffff 7 2000000c 04A26701 there: .dc.l 23568900 8 .end ^LARM GAS l.s page 2 DEFINED SYMBOLS l.s:6 .text:0000000020000008 here .text:0000000000000000 $d l.s:3 .text:0000000020000000 $a l.s:4 .text:0000000020000004 branch l.s:6 .text:0000000020000008 $d l.s:7 .text:000000002000000c there NO UNDEFINED SYMBOLS