.intel_syntax noprefix .section .text .global switch_thread switch_thread: push ebx push ebp push edi push esi mov eax, [current_tcb] // save the current stack pointer to the old stack mov [eax+0], esp // stack pointer + the 4 regs pushed // and + 1 to get the argument (next thread) mov esi, [esp+(4+1)*4] mov [current_tcb], esi mov eax, [current_tcb] mov esp, [eax+0] // get esp pop esi pop edi pop ebp pop ebx iret