-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread_asm.s
More file actions
43 lines (33 loc) · 890 Bytes
/
Copy paththread_asm.s
File metadata and controls
43 lines (33 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%if CHAPTER >= 9
;;;
;;; thread.s -- Declares functions for thread switching.
;;; Written for JamesM's kernel development tutorials.
;;;
[global switch_thread]
[global _create_thread]
[extern current_thread]
[extern thread_exit]
switch_thread:
mov eax, [current_thread]
mov eax, [eax]
mov [eax+0], esp
mov [eax+4], ebp
mov [eax+8], ebx
mov [eax+12], esi
mov [eax+16], edi
pushf
pop ecx
mov [eax+20], ecx
mov eax, [esp+4]
mov [current_thread], eax
mov eax, [eax]
mov esp, [eax+0]
mov ebp, [eax+4]
mov ebx, [eax+8]
mov esi, [eax+12]
mov edi, [eax+16]
mov eax, [eax+20]
push eax
popf
ret
%endif ; CHAPTER >= 9