pass variables into inline assembly ( I am confused)
Posted: Fri Apr 10, 2020 5:48 pm
I read the tutorial the only way to pass variables into inline assembly is using input and output list
but I came across with early linux context switch code (below) it seems that the variable _current is being passed
into assembly as if it is a variable in C.. notice this is the only place this happens... the rest of the variable is being passed
using the standard extended assembly convention with input list, output list and then followed by a clobbered list...
but I came across with early linux context switch code (below) it seems that the variable _current is being passed
into assembly as if it is a variable in C.. notice this is the only place this happens... the rest of the variable is being passed
using the standard extended assembly convention with input list, output list and then followed by a clobbered list...
Code: Select all
#define switch_to(n) {
struct {long a,b;} __tmp;
__asm__("cmpl %%ecx,[color=#0000FF]_current[/color]\n\t"
"je 1f\n\t"
"xchgl %%ecx,_current\n\t"
"movw %%dx,%1\n\t"
"ljmp %0\n\t"
"cmpl %%ecx,%2\n\t"
"jne 1f\n\t"
"clts\n"
"1:"
::"m" (*&__tmp.a),
"m" (*&__tmp.b),
"m" (last_task_used_math),
"d" _TSS(n),
"c" ((long) task[n]));
}