inline assembly input output list question
Posted: Wed Sep 02, 2020 2:31 am
I was studying linux 2.2 kernel context switching code... I found out that the register
eax, edx and ecx, appear both in the output and input section of the inline assembly...
Why is it a good idea? Are output assignment executed or input assignment done first?
the order of the execution determined the output, isn't this dangerous?
eax, edx and ecx, appear both in the output and input section of the inline assembly...
Why is it a good idea? Are output assignment executed or input assignment done first?
the order of the execution determined the output, isn't this dangerous?
Code: Select all
/** include/asm-i386/system.h */
#define switch_to(prev,next) do {
unsigned long eax, edx, ecx;
asm volatile("pushl %%ebx\n\t"
"pushl %%esi\n\t"
"pushl %%edi\n\t"
"pushl %%ebp\n\t"
"movl %%esp,%0\n\t" /* save ESP */
"movl %5,%%esp\n\t" /* restore ESP */
"movl $1f,%1\n\t" /* save EIP */
"pushl %6\n\t" /* restore EIP */
"jmp __switch_to\n"
"1:\t"
"popl %%ebp\n\t"
"popl %%edi\n\t"
"popl %%esi\n\t"
"popl %%ebx"
:"=m" (prev->tss.esp),"=m" (prev->tss.eip),
"=a" (eax), "=d" (edx), "=c" (ecx)
:"m" (next->tss.esp),"m" (next->tss.eip),
"a" (prev), "d" (next));
} while (0)