diff --git a/src/multitasking/switch_to_task.s b/src/multitasking/switch_to_task.s index d542361..555dd14 100644 --- a/src/multitasking/switch_to_task.s +++ b/src/multitasking/switch_to_task.s @@ -9,11 +9,14 @@ switch_to_task: push edi push esi - // save the current stack pointer to the old stack - mov [current_task+0], esp + mov eax, [current_task] - mov edi, [esp_backup] // get eip - mov [current_task+16], edi // save instruction before Interrupt + // save the current stack pointer to the old stack + mov [eax+0], esp + + // save the old eip pointer + mov ebx, [[esp_backup]] + mov [eax+16], ebx // stack pointer + the 4 regs pushed // and + 1 to get the argument (next task) @@ -22,21 +25,22 @@ switch_to_task: mov esp, [current_task] // esp mov eax, [current_task+4] // esp0 - mov ebx, [current_task+8] // cr3 - mov edi, [current_task+12] // page_directory - mov [page_directory], edi - mov [TSS+4], eax // tss.esp0 - mov ecx, cr3 +// mov ebx, [current_task+8] // cr3 +// mov edi, [current_task+12] // page_directory +// mov [page_directory], edi +// mov [TSS+4], eax // tss.esp0 +// mov ecx, cr3 // if cr3 hasn't change, do nothing - cmp ecx, ebx - je .END +// cmp ecx, ebx +// je .END // mov cr3, ebx .END: - mov edi, [current_task+16] - mov [esp_backup], edi + mov eax, [current_task+16] + mov ebx, [esp_backup] + mov [ebx], eax pop esi pop edi