1# 2# $Id: prt0_10.as,v 1.1 2004/01/04 01:13:23 marco 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# NetBSD standard (static) ELF/i386 startup code for Free Pascal 18# 19 20 21 .file "prt0.s" 22 .version "01.01" 23gcc2_compiled.: 24.globl __progname 25 26.section .rodata 27.LC0: 28 .ascii "\0" 29.data 30 .align 4 31 .type __progname,@object 32 .size __progname,4 33__progname: 34 .long .LC0 35.globl __ps_strings 36 .align 4 37 .type __ps_strings,@object 38 .size __ps_strings,4 39__ps_strings: 40 .long 0 41 .align 4 42___fpucw: 43 .long 0x1332 44 45 .globl ___fpc_brk_addr /* heap management */ 46 .type ___fpc_brk_addr,@object 47 .size ___fpc_brk_addr,4 48___fpc_brk_addr: 49 .long 0 50 51#APP 52 53 .text 54 .align 4 55 .globl __start 56 .globl _start 57_start: 58__start: 59 pushl %ebx # ps_strings 60 pushl %ecx # obj 61 pushl %edx # cleanup 62 movl 12(%esp),%eax 63 leal 20(%esp,%eax,4),%ecx 64 leal 16(%esp),%edx 65 pushl %ecx 66 pushl %edx 67 pushl %eax 68 call ___start 69 70#NO_APP 71.text 72 .align 4 73.globl ___start 74 .type ___start,@function 75___start: 76 pushl %ebp 77 movl %esp,%ebp 78 movl 16(%ebp),%eax 79 movl %eax,environ 80 movl %eax,U_SYSBSD_ENVP 81 movl 8(%ebp),%eax 82 movl %eax,U_SYSBSD_ARGC 83 movl 12(%ebp),%eax 84 movl %eax,U_SYSBSD_ARGV 85 movl (%eax),%edx 86 movl %edx,__progname 87 testl %edx,%edx 88 je .L2 89 pushl $47 90 movl __progname,%eax 91 pushl %eax 92 call _strrchr 93 addl $8,%esp 94 movl %eax,%eax 95 movl %eax,__progname 96 cmpl $0,__progname 97 jne .L3 98 movl 12(%ebp),%eax 99 movl (%eax),%edx 100 movl %edx,__progname 101 jmp .L2 102 .align 4 103.L3: 104 incl __progname 105.L4: 106.L2: 107 cmpl $0,28(%ebp) 108 je .L5 109 movl 28(%ebp),%eax 110 movl %eax,__ps_strings 111.L5: 112# pushl $_fini 113# call atexit 114# addl $4,%esp 115# call _init 116# copied from linux 117 118 finit /* initialize fpu */ 119 fwait 120 fldcw ___fpucw 121 122 xorl %ebp,%ebp 123 124 call main 125 pushl %eax 126 jmp _haltproc 127 128.p2align 2,0x90 129.globl _haltproc 130.type _haltproc,@function 131 132_haltproc: 133 mov $1,%eax 134 movzwl U_SYSBSD_EXITCODE,%ebx 135 pushl %ebx 136 call _actualsyscall 137 addl $4,%esp 138 jmp _haltproc 139 140_actualsyscall: 141 int $0x80 142 jb .LErrorcode 143 xor %ebx,%ebx 144 ret 145.LErrorcode: 146 mov %eax,%ebx 147 mov $-1,%eax 148 ret 149 .p2align 2,0x90 150 151.Lfe1: 152 .size ___start,.Lfe1-___start 153 .align 4 154 .type _strrchr,@function 155_strrchr: 156 pushl %ebp 157 movl %esp,%ebp 158 subl $8,%esp 159 movl 12(%ebp),%eax 160 movb %al,-1(%ebp) 161 movl $0,-8(%ebp) 162 .align 4 163.L7: 164 movl 8(%ebp),%eax 165 movb (%eax),%dl 166 cmpb -1(%ebp),%dl 167 jne .L10 168 movl 8(%ebp),%eax 169 movl %eax,-8(%ebp) 170.L10: 171 movl 8(%ebp),%eax 172 cmpb $0,(%eax) 173 jne .L9 174 movl -8(%ebp),%edx 175 movl %edx,%eax 176 jmp .L6 177 .align 4 178.L11: 179.L9: 180 incl 8(%ebp) 181 jmp .L7 182 .align 4 183.L8: 184.L6: 185 leave 186 ret 187 188 189.Lfe2: 190 .size _strrchr,.Lfe2-_strrchr 191 .comm environ,4,4 192 193# This section is needed for NetBSD to recognize a NetBSD binary as such. 194# otherwise it will be startup in Linux emulation mode. 195 196.section ".note.netbsd.ident","a" 197.p2align 2 198 199.long 7 200.long 4 201# ELF NOTE TYPE NETBSD TAG 202.long 1 203.ascii "NetBSD\0\0" 204.long 199905 205