Search code examples
gccarmcross-compilingarmcc

arm instruction ldr error on gcc works fine on armcc


LDR     r2, =0x0 :OR: (Region_64K << 1) :OR: Region_Enable

What does the above command do ? on armcc it compiles fine while with arm-none-eabi-gcc it gives an error

garbage following instruction -- `ldr r2,=0x0:OR:(Region_64K<<1):OR:Region_Enable'

where on gcc

Region_Enable = 0b1
Region_64K   = 0b01111

on armcc

Region_Enable EQU 2_1
Region_64K   EQU 2_01111

Solution

  • It's armasm's syntax for bitwise operators in expressions. For the GNU assembler, you'll want | instead of :OR:.

    Since armasm claims that using | as an alias is deprecated for some reason (although & for :AND: and ^ for :EOR: are apparently fine), you may need to resort to some preprocessor magic if you want to maintain compatibility with both toolchains.