Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

incorrect register '%rbx' used with 'l' suffix

I'm trying to compile this code under linux with gcc compiler :

static inline unsigned long get_current(void)
{
    unsigned long current;

    asm volatile (
    " movl %%esp, %%eax;"
    " andl %1, %%eax;"
    " movl (%%eax), %0;"
    : "=r" (current)
    : "i" (0xfffff000)
    );
    return current;
}

But i'm getting this error :

program.c: Assembler messages: program.c:455: Error: incorrect
register `%rbx' used with `l' suffix

what is wrong here ?

like image 533
Ouerghi Yassine Avatar asked Jan 05 '13 12:01

Ouerghi Yassine


1 Answers

Obviously, you're compiling for 64 bits. Try using gcc -m32 if it's not what you want, or use 64-bit registers (%esp makes no sense at all on x64).

like image 71
Anton Kovalenko Avatar answered Nov 08 '22 07:11

Anton Kovalenko