syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / com32 / lib / sys / exit.S
1 # $Id: exit.S,v 1.2 2004/12/17 19:40:41 hpa Exp $
2 #
3 # Implementation of _exit() for com32 based on c32entry.S
4 #
5         .text
6         .globl _exit
7         .type _exit, @function
8 _exit:
9 #ifdef REGPARM
10         pushl %eax
11 #endif
12         
13         # Run any destructors
14         movl $__dtors_start, %esi
15 2:
16         cmpl $__dtors_end, %esi
17         jae 1f
18         call *(%esi)
19         addl $4,%esi
20         jmp 2b
21         
22 1:
23 #ifdef REGPARM
24         popl %eax
25 #else
26         movl 4(%esp),%eax               # Exit code in %eax = return value
27 #endif
28         movl (__entry_esp),%esp         # Return stack pointer to entry value
29         ret                             # Return to termination address
30         .size _exit, .-_exit
31
32         .data
33 __exit_handler:
34         .globl __exit_handler
35         .long _exit