c - Error - invalid 'asm': operand number missing after %-letter -


i'm writing inline assembly code in program. wrote below code , compiled source file, named 'context.c'. compiler consistently shows error message.

 context.c:42:2: error:  invalid 'asm': operand number missing after %-letter     __asm__ __volatile__(     ^ 

i searched every article has same error message me, , read inline assembly manual carefully. can't find fault code. please help!

    void _os_restore_context(addr_t sp){     __asm__ __volatile__(     //line 42             "movl %0, %%esp             \n\t"             "popl %%edi                 \n\t"             "popl %%esi                 \n\t             "popl %%ebp                 \n\t             "addl $4, %%esp #pass esp   \n\t             "popl %%ebx                 \n\t             "popl %%edx                 \n\t             "popl %%ecx                 \n\t             "popl %%eax                 \n\t             "popl %eflags               \n\t             "addl $4, %%esp #pass eip   \n\t             "popl %%ebp                 \n\t             "ret                        \n\t             :: "m" (sp) : "%eax"         );     } 

i solved problem. reason eflags register. eflags , eip register has special purpose, user program cannot access it.

to give more information, code part of small operating system, made learning os. os, named eos(educational operation system), has hardware emulator source code in other section, , eflags register defined register variable in section, written in assembly language. so, i'm advised replace %eflags _eflags, name of register variable. after that, error goes out.

have nice day!