Search code examples
gccassemblymacrosgnu-assembler

error: junk `bswapl eax movl %eax' after register


I define a MACRO in GAS source code. But it is not compiled by gcc.

The following is my defined MACRO.

#define MSGSCHEDULE0(index) \
    movl (index*4)(%rsi)    ,%eax \
    bswapl eax \
    movl %eax   ,(index*4-272)(%rdi)

The below is Assembler messages:

error: junk `bswapl eax movl %eax' after register

I want to use this MACRO in my code as following:

MSGSCHEDULE0(0)
MSGSCHEDULE0(1)
MSGSCHEDULE0(2)
//...
MSGSCHEDULE0(16)

Solution

  • Use a semicolon to signal GAS the end of line:

    #define MSGSCHEDULE0(index) \
        movl (index*4)(%rsi),%eax; \
        bswapl %eax; \
        movl %eax,(index*4-272)(%rdi)
    

    Don't forget the percentage sign for registers.