assemblyarmgnu-assembler

How to use shifter operands in GNU arm assembly syntax?


I know in arm assembly we can use shifter operands like bellow:

mov r0, r1, lsl #2

I use gcc to compile, therefore I have to adapt syntax.

I already tried this:

mov w0, w1, lsl 2

It didn't work: unexpected characters following instruction at operand 2. To me it says it can't handle the third operand.

Is there any alternative syntax that does the same job in gnu?


Solution

  • mov r0, r1, lsl #2 works fine for me in gnu as.

    I have GNU assembler (2.35.2-2+14+b2) 2.35.2

    Probably you didn't specify the correct command line flags or options in the file.

    Try adding to the top of your file something like:

    .syntax   unified
    .cpu      cortex-m4