1#
2#   $Id: gprt0.as,v 1.3 2004/07/03 21:50:30 daniel Exp $
3#   This file is part of the Free Pascal run time library.
4#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
5#                                                  and Peter Vreman
6#   members of the Free Pascal development team.
7#
8#   See the file COPYING.FPC, included in this distribution,
9#   for details about the copyright.
10#
11#   This program is distributed in the hope that it will be useful,
12#   but WITHOUT ANY WARRANTY;without even the implied warranty of
13#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14#
15#**********************************************************************}
16#
17# FreeBSD ELF startup code for Free Pascal for dynamical linking to libc
18# with profiling support.
19#
20
21	.file	"gpcrt1.c"
22	.version	"01.01"
23gcc2_compiled.:
24.section	.note.ABI-tag,"a",@progbits
25	.p2align 2
26	.type	 abitag,@object
27	.size	 abitag,24
28abitag:
29	.long 8
30	.long 4
31	.long 1
32	.byte	 0x46,0x72,0x65,0x65,0x42,0x53,0x44,0x0
33	.long	900044
34
35.globl __progname
36	.section	.rodata
37.LC0:
38	.byte	 0x0
39.data
40	.p2align 2
41	.type	 __progname,@object
42	.size	 __progname,4
43__progname:
44	.long .LC0
45
46        .align  4
47___fpucw:
48        .long   0x1332
49
50        .globl  ___fpc_brk_addr         /* heap management */
51        .type   ___fpc_brk_addr,@object
52        .size   ___fpc_brk_addr,4
53___fpc_brk_addr:
54        .long   0
55
56.text
57	.p2align 2,0x90
58.globl _start
59		.type		 _start,@function
60_start:
61#APP
62	movl %edx,%edx
63#NO_APP
64	pushl %ebp
65	movl %esp,%ebp
66	subl $12,%esp
67	pushl %edi
68	pushl %esi
69	pushl %ebx
70	movl 4(%ebp),%ebx
71	movl %ebx,operatingsystem_parameter_argc
72	leal 12(%ebp,%ebx,4),%esi
73	leal 8(%ebp),%eax
74	movl %eax,operatingsystem_parameter_argv
75	movl %eax,-4(%ebp)
76	movl %esi,operatingsystem_parameter_envp
77	movl %esi,environ
78	movl $_DYNAMIC,%ecx
79	testl %ebx,%ebx
80	jle .L3
81	movl 8(%ebp),%eax
82	testl %eax,%eax
83	je .L3
84	movl %eax,__progname
85	cmpb $0,(%eax)
86	je .L3
87	.p2align 2,0x90
88.L7:
89	cmpb $47,(%eax)
90	jne .L6
91	leal 1(%eax),%edi
92	movl %edi,__progname
93.L6:
94	incl %eax
95	cmpb $0,(%eax)
96	jne .L7
97.L3:
98	testl %ecx,%ecx
99	je .L10
100	addl $-12,%esp
101	pushl %edx
102	call atexit
103	addl $16,%esp
104.L10:
105	addl $-12,%esp
106	pushl $_mcleanup
107	call atexit
108	addl $-12,%esp
109	pushl $_fini
110	call atexit
111	addl $32,%esp
112	addl $-8,%esp
113	pushl $etext
114	pushl $eprol
115	call monstartup
116	call _init
117
118        finit                           /* initialize fpu */
119        fwait
120        fldcw   ___fpucw
121        xorl    %ebp,%ebp
122	call  main
123	pushl %eax
124	jmp  _haltproc
125
126.globl _haltproc
127.type _haltproc,@function
128_haltproc:
129           movzwl operatingsystem_result,%ebx
130           pushl %ebx
131	   call  exit
132           mov $1,%eax
133           movzwl operatingsystem_result,%ebx
134	   pushl %ebx
135           call .Lactualsyscall
136           addl  $4,%esp
137           jmp   _haltproc
138
139.Lactualsyscall:
140         int $0x80
141         jb .LErrorcode
142         xor %ebx,%ebx
143         ret
144.LErrorcode:
145         mov %eax,%ebx
146         mov $-1,%eax
147         ret
148        .p2align 2,0x90
149.Lfe1:
150		.size		 _start,.Lfe1-_start
151#APP
152	.text
153	eprol:
154	.previous
155#NO_APP
156	.comm	environ,4,4
157	.globl	_DYNAMIC
158	.weak	_DYNAMIC
159	.ident	"GCC: (GNU) c 2.95.4 20020320 [FreeBSD]"
160
161.bss
162        .comm operatingsystem_parameter_envp,4
163        .comm operatingsystem_parameter_argc,4
164        .comm operatingsystem_parameter_argv,4
165