initial commit
[metatoy] / src / kern / regs.asm
1         section .text
2         align 4
3
4         global get_regs
5 get_regs:
6         push ebp
7         mov ebp, esp
8
9         push edx
10         mov edx, [ebp + 8]
11
12         mov [edx], eax
13         mov [edx + 4], ebx
14         mov [edx + 8], ecx
15         
16         ; juggle edx
17         mov eax, edx
18         pop edx
19         mov [eax + 12], edx
20         push edx
21         mov edx, eax
22         
23         ; those two are pointless in a function
24         mov [edx + 16], esp
25         mov [edx + 20], ebp
26
27         mov [edx + 24], esi
28         mov [edx + 28], edx
29
30         pushf
31         pop eax
32         mov [edx + 32], eax
33
34         mov [edx + 36], cs
35         mov [edx + 40], ss
36         mov [edx + 44], ds
37         mov [edx + 48], es
38         mov [edx + 52], fs
39         mov [edx + 56], gs
40
41         push ebx
42         mov ebx, cr0
43         mov [edx + 60], ebx
44         ;mov ebx, cr1
45         ;mov [edx + 64], ebx
46         mov ebx, cr2
47         mov [edx + 68], ebx
48         mov ebx, cr3
49         mov [edx + 72], ebx
50         pop ebx
51
52         pop edx
53         pop ebp
54         ret
55
56
57 ; vi:set ts=8 sts=8 sw=8 ft=nasm: