Files
42_KFS/src/multitasking/switch_to_thread.s
2025-11-05 16:19:21 +01:00

32 lines
447 B
ArmAsm

.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