net: partial implementation of tcp
[quarnos.git] / libs / setjmp.s
blob6de57864cc2b7bcc62644a38ae1c0c37b8dfe616
1 /* Quarn OS
3 * setjmp and longjmp functions
5 * Copyright (C) 2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 .global __setjmp
24 __setjmp:
25 /* Get structure from pointer */
26 movl 4(%esp), %edx
28 /* Save return address */
29 movl (%esp), %eax
30 movl %eax, 12(%edx)
32 /* Save stack pointer */
33 movl %esp, (%edx)
35 /* Save base pointer */
36 movl %ebp, 4(%edx)
38 /* Save flags */
39 pushf
40 popl %eax
41 movl %eax, 8(%edx)
43 /* Clear eax */
44 xorl %eax, %eax
46 ret
48 .global __longjmp
49 __longjmp:
50 movl %esp, %edx
52 /* Restore stack pointer */
53 movl 4(%edx), %esp
55 /* Restore base pointer */
56 movl 8(%edx), %ebp
58 /* Restore flags */
59 movl 12(%edx), %eax
60 pushl %eax
61 popf
63 /* Set eax */
64 movl 20(%edx), %eax
66 /* Return */
67 movl 16(%edx), %edx
68 pushl %edx
70 ret