Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / rtl / linux / i386 / gprt21.as
blobca83e67f8a407f625a566fc95a886f98ec0bb045
2 # $Id$
3 # This file is part of the Free Pascal run time library.
4 # Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
5 # members of the Free Pascal development team.
7 # See the file COPYING.FPC, included in this distribution,
8 # for details about the copyright.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY;without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 #**********************************************************************}
16 # Linux ELF startup code for Free Pascal
19 .file "prt1.as"
20 .text
21 .globl _start
22 .type _start,@function
23 _start:
24 /* First locate the start of the environment variables */
25 popl %esi
26 movl %eax,%edi
28 movl %esp,%ebx /* Points to the arguments */
29 movl %esi,%eax
30 incl %eax
31 shll $2,%eax
32 addl %esp,%eax
33 andl $0xfffffff8,%esp /* Align stack */
35 movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */
36 movl %esi,U_SYSLINUX_ARGC /* Move the argument counter */
37 movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */
39 movl %edi,%eax
40 xorl %ebp,%ebp
41 pushl %eax
42 pushl %esp
43 pushl %edx
44 pushl $_fini
45 pushl $_init
46 pushl %ebx
47 pushl %esi
48 pushl $main
49 call __libc_start_main
50 hlt
52 /* fake main routine which will be run from libc */
53 .globl cmain
54 .type cmain,@object
55 cmain:
56 /* save return address */
57 popl %eax
58 movl %eax,___fpc_ret
59 movl %ebx,___fpc_ret_ebx
60 movl %esi,___fpc_ret_esi
61 movl %edi,___fpc_ret_edi
62 pushl %eax
64 /* start the program */
65 call PASCALMAIN
67 .globl _haltproc
68 .type _haltproc,@function
69 _haltproc:
70 xorl %eax,%eax /* load and save exitcode */
71 movw U_SYSLINUX_EXITCODE,%ax
73 movl ___fpc_ret,%edx /* return to libc */
74 movl ___fpc_ret_ebx,%ebx
75 movl ___fpc_ret_esi,%esi
76 movl ___fpc_ret_edi,%edi
77 push %edx
78 ret
80 .globl __gmon_start__
81 .type __gmon_start__,@object
82 __gmon_start__:
83 pushl %ebp
84 movl __monstarted,%eax
85 leal 0x1(%eax),%edx
86 movl %esp,%ebp
87 movl %edx,__monstarted
88 testl %eax,%eax
89 jnz .Lnomonstart
90 pushl $etext /* Initialize gmon */
91 pushl $_start
92 call monstartup
93 addl $8,%esp
94 pushl $_mcleanup
95 call atexit
96 addl $4,%esp
97 .Lnomonstart:
98 movl %ebp,%esp
99 popl %ebp
102 .data
103 .align 4
105 .globl ___fpc_brk_addr /* heap management */
106 .type ___fpc_brk_addr,@object
107 .size ___fpc_brk_addr,4
108 ___fpc_brk_addr:
109 .long 0
111 ___fpc_ret: /* return address to libc */
112 .long 0
113 ___fpc_ret_ebx:
114 .long 0
115 ___fpc_ret_esi:
116 .long 0
117 ___fpc_ret_edi:
118 .long 0
120 .bss
121 .lcomm __monstarted,4
124 # $Log$
125 # Revision 1.1 2002/02/19 08:25:40 sasu
126 # Initial revision
128 # Revision 1.1 2000/07/13 06:30:55 michael
129 # + Initial import
131 # Revision 1.4 2000/01/07 16:41:42 daniel
132 # * copyright 2000
134 # Revision 1.3 2000/01/07 16:32:28 daniel
135 # * copyright 2000 added
137 # Revision 1.2 1999/05/03 23:30:29 peter
138 # * small update
139 # * uses gprt1 again for gprt21 becuase gprt21.as crashes
141 # Revision 1.1 1999/05/03 21:29:36 peter
142 # + glibc 2.1 support
144 # Revision 1.3 1998/11/04 10:16:25 peter
145 # + xorl ebp,ebp to indicate end of backtrace
147 # Revision 1.2 1998/10/14 21:28:46 peter
148 # * initialize fpu so sigfpe is finally generated for fpu errors
150 # Revision 1.1 1998/08/12 19:16:09 peter
151 # + loader including libc init and exit