Adding upstream version 6.03~pre1+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / setjmp.S
blob2fb5c234c3aabc9f44363b15dc5208855f35b631
1 /*
2  * arch/i386/setjmp.S
3  *
4  * setjmp/longjmp for the i386 architecture
5  *
6  *
7  *
8  * The jmp_buf is assumed to contain the following, in order:
9  *      %ebx
10  *      %esp
11  *      %ebp
12  *      %esi
13  *      %edi
14  *      <return address>
15  */
17         .text
18         .align 4
20         .globl _setjmp
21         .type _setjmp, @function
22 _setjmp:                                # gcc 4.0.1 wants this as an alias?
24         .globl setjmp
25         .type setjmp, @function
26 setjmp:
27 #ifdef REGPARM
28         movl %eax,%edx
29 #else
30         movl 4(%esp),%edx
31 #endif
32         popl %ecx                       # Return address, and adjust the stack
33         xorl %eax,%eax                  # Return value
34         movl %ebx,(%edx)
35         movl %esp,4(%edx)               # Post-return %esp!
36         pushl %ecx                      # Make the call/return stack happy
37         movl %ebp,8(%edx)
38         movl %esi,12(%edx)
39         movl %edi,16(%edx)
40         movl %ecx,20(%edx)              # Return address
41         ret
43         .size setjmp,.-setjmp
45         .text
46         .align 4
47         .globl longjmp
48         .type longjmp, @function
49 longjmp:
50 #ifdef REGPARM
51         xchgl %eax,%edx
52 #else
53         movl 4(%esp),%edx               # jmp_ptr address
54         movl 8(%esp),%eax               # Return value
55 #endif
56         movl (%edx),%ebx
57         movl 4(%edx),%esp
58         movl 8(%edx),%ebp
59         movl 12(%edx),%esi
60         movl 16(%edx),%edi
61         jmp *20(%edx)
63         .size longjmp,.-longjmp
65 #if __SIZEOF_POINTER__ == 4
66 #include <i386/setjmp.S>
67 #elif __SIZEOF_POINTER__ == 8
68 #include <x86_64/setjmp.S>
69 #else
70 #error "Unable to build for to-be-defined architecture type"
71 #endif