census logo
[bootcensus] / src / regs.s
1 # pcboot - bootable PC demo/game kernel
2 # Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
3
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17         .text
18         .align 4
19
20         .globl get_regs
21 get_regs:
22         pushl %ebp
23         movl %esp, %ebp
24
25         pushl %edx
26         movl 8(%ebp), %edx
27
28         movl %eax, (%edx)
29         movl %ebx, 4(%edx)
30         movl %ecx, 8(%edx)
31         
32         # juggle edx
33         movl %edx, %eax
34         popl %edx
35         movl %edx, 12(%eax)
36         pushl %edx
37         movl %eax, %edx
38         
39         # those two are pointless in a function
40         movl %esp, 16(%edx)
41         movl %ebp, 20(%edx)
42
43         movl %esi, 24(%edx)
44         movl %edi, 28(%edx)
45
46         pushf
47         popl %eax
48         movl %eax, 32(%edx)
49
50         movw %cs, 36(%edx)
51         movw %ss, 40(%edx)
52         movw %ds, 44(%edx)
53         movw %es, 48(%edx)
54         movw %fs, 52(%edx)
55         movw %gs, 56(%edx)
56
57         pushl %ebx
58         movl %cr0, %ebx
59         movl %ebx, 60(%edx)
60         #movl %cr1, %ebx
61         #movl %ebx, 64(%edx)
62         movl %cr2, %ebx
63         movl %ebx, 68(%edx)
64         movl %cr3, %ebx
65         movl %ebx, 72(%edx)
66         popl %ebx
67
68         popl %edx
69         popl %ebp
70         ret