From c63b960e6a8948e95f39c5a3a6c39a7f57009ac3 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Mon, 11 Jul 2022 14:35:45 +0200 Subject: [PATCH] fix bug where ebx was saved incorrectly on preempt --- c_os/kernel/threads/Thread.asm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/c_os/kernel/threads/Thread.asm b/c_os/kernel/threads/Thread.asm index 0b9ae86..7cea8e6 100755 --- a/c_os/kernel/threads/Thread.asm +++ b/c_os/kernel/threads/Thread.asm @@ -96,10 +96,6 @@ Thread_switch: push eax ; backup eax before using it as index mov eax, [esp + 0x8] - pushf ; store eflags - pop ebx - mov [eax + efl_offset], ebx - add esp, 0x4 ; store the original esp mov [eax + esp_offset], esp sub esp, 0x4 @@ -111,6 +107,10 @@ Thread_switch: mov [eax + ecx_offset], ecx mov [eax + edx_offset], edx + pushf ; store eflags + pop ebx + mov [eax + efl_offset], ebx + pop ebx ; store eax mov [eax + eax_offset], ebx @@ -128,7 +128,6 @@ Thread_switch: mov esp, [eax + esp_offset] mov ecx, [eax + ecx_offset] mov edx, [eax + edx_offset] - mov eax, [eax + eax_offset] ; restore eax ;; Enable interrupts again