summaryrefslogtreecommitdiff
path: root/kernel/asm.s
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/asm.s')
-rw-r--r--kernel/asm.s60
1 files changed, 60 insertions, 0 deletions
diff --git a/kernel/asm.s b/kernel/asm.s
new file mode 100644
index 0000000..4abe607
--- /dev/null
+++ b/kernel/asm.s
@@ -0,0 +1,60 @@
+global switch_to
+extern ctask
+extern tss
+
+switch_to:
+ push ebp
+ mov ebp, esp
+ mov eax, [ebp+8]
+ mov [ctask], eax
+ mov esi, [ebp+12]
+ mov ecx, 13
+.loop:
+ lodsd
+ push eax
+ dec ecx
+ jz .end
+ jmp .loop
+.end:
+ mov ax, 0x23
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+ popa
+ iret
+
+; uint32_t ss;
+; uint32_t esp;
+; uint32_t eflags;
+; uint32_t cs;
+; uint32_t eip;
+; uint32_t eax;
+; uint32_t ecx;
+; uint32_t edx;
+; uint32_t ebx;
+; uint32_t esp_garbage;
+; uint32_t ebp;
+; uint32_t esi;
+; uint32_t edi;
+
+; switch_to:
+ ; push ebp
+ ; mov ebp, esp
+ ; cli
+ ; mov ax, 0x23
+ ; mov ds, ax
+ ; mov es, ax
+ ; mov fs, ax
+ ; mov gs, ax
+ ; mov eax, esp
+ ; ; save ESP in the TSS
+ ; mov [tss+4], eax
+ ; push dword 0x23
+ ; push dword 0x00180000
+ ; pushf
+ ; push dword 0x1B
+ ; push dword 0x00100000
+ ; iret
+ ; pop ebp
+ ; ret