mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 06:19:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			164 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			ActionScript
		
	
	
	
	
	
			
		
		
	
	
			164 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			ActionScript
		
	
	
	
	
	
#
 | 
						|
#   $Id: prt0.as,v 1.2 2004/01/04 01:13:23 marco Exp $
 | 
						|
#   This file is part of the Free Pascal run time library.
 | 
						|
#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
 | 
						|
#                                                  and Peter Vreman
 | 
						|
#   members of the Free Pascal development team.
 | 
						|
#
 | 
						|
#   See the file COPYING.FPC, included in this distribution,
 | 
						|
#   for details about the copyright.
 | 
						|
#
 | 
						|
#   This program is distributed in the hope that it will be useful,
 | 
						|
#   but WITHOUT ANY WARRANTY;without even the implied warranty of
 | 
						|
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | 
						|
#
 | 
						|
#**********************************************************************}
 | 
						|
#
 | 
						|
# NetBSD standard (static) ELF/i386 startup code for Free Pascal
 | 
						|
#
 | 
						|
 | 
						|
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/i386/crt0.c?rev=1.33&content-type=text/x-cvsweb-markup
 | 
						|
 | 
						|
	.file	"prt0.s"
 | 
						|
	.version	"01.01"
 | 
						|
gcc2_compiled.:
 | 
						|
.globl __progname
 | 
						|
 | 
						|
.section	.rodata
 | 
						|
.LC0:
 | 
						|
	.ascii "\0"
 | 
						|
.data
 | 
						|
	.align 4
 | 
						|
	.type	 __progname,@object
 | 
						|
	.size	 __progname,4
 | 
						|
__progname:
 | 
						|
	.long .LC0
 | 
						|
.globl __ps_strings
 | 
						|
	.align 4
 | 
						|
	.type	 __ps_strings,@object
 | 
						|
	.size	 __ps_strings,4
 | 
						|
__ps_strings:
 | 
						|
	.long 0
 | 
						|
	.align 4
 | 
						|
___fpucw:
 | 
						|
        .long   0x1332
 | 
						|
 | 
						|
        .globl  ___fpc_brk_addr         /* heap management */
 | 
						|
        .type   ___fpc_brk_addr,@object
 | 
						|
        .size   ___fpc_brk_addr,4
 | 
						|
___fpc_brk_addr:
 | 
						|
        .long   0
 | 
						|
 | 
						|
#APP
 | 
						|
	
 | 
						|
	.text
 | 
						|
	.align	4
 | 
						|
	.globl	__start
 | 
						|
	.globl	_start
 | 
						|
_start:
 | 
						|
__start:
 | 
						|
	pushl	%ebx			# ps_strings
 | 
						|
	pushl	%ecx			# obj
 | 
						|
	pushl	%edx			# cleanup
 | 
						|
	movl	12(%esp),%eax
 | 
						|
	leal	20(%esp,%eax,4),%ecx
 | 
						|
	leal	16(%esp),%edx
 | 
						|
	pushl	%ecx
 | 
						|
	pushl	%edx
 | 
						|
	pushl	%eax
 | 
						|
	call	___start
 | 
						|
 | 
						|
#NO_APP
 | 
						|
.text
 | 
						|
	.align 4
 | 
						|
.globl ___start
 | 
						|
	.type	 ___start,@function
 | 
						|
___start:
 | 
						|
	pushl %ebp
 | 
						|
	movl %esp,%ebp
 | 
						|
	movl 16(%ebp),%eax
 | 
						|
	movl %eax,environ
 | 
						|
	movl %eax,U_SYSTEM_ENVP
 | 
						|
	movl 8(%ebp),%eax
 | 
						|
	movl %eax,U_SYSTEM_ARGC
 | 
						|
	movl 12(%ebp),%eax
 | 
						|
	movl %eax,U_SYSTEM_ARGV
 | 
						|
	movl (%eax),%edx
 | 
						|
	movl %edx,__progname
 | 
						|
	testl %edx,%edx
 | 
						|
	je .L2
 | 
						|
	pushl $47
 | 
						|
	movl __progname,%eax
 | 
						|
	pushl %eax
 | 
						|
	call _strrchr
 | 
						|
	addl $8,%esp
 | 
						|
	movl %eax,%eax
 | 
						|
	movl %eax,__progname
 | 
						|
	cmpl $0,__progname
 | 
						|
	jne .L3
 | 
						|
	movl 12(%ebp),%eax
 | 
						|
	movl (%eax),%edx
 | 
						|
	movl %edx,__progname
 | 
						|
	jmp .L2
 | 
						|
	.align 4
 | 
						|
.L3:
 | 
						|
	incl __progname
 | 
						|
.L4:
 | 
						|
.L2:
 | 
						|
	cmpl $0,28(%ebp)
 | 
						|
	je .L5
 | 
						|
	movl 28(%ebp),%eax
 | 
						|
	movl %eax,__ps_strings
 | 
						|
.L5:
 | 
						|
#	pushl $_fini
 | 
						|
#	call atexit
 | 
						|
#	addl $4,%esp
 | 
						|
#	call _init
 | 
						|
# copied from linux
 | 
						|
 | 
						|
        finit                           /* initialize fpu */
 | 
						|
        fwait
 | 
						|
        fldcw   ___fpucw
 | 
						|
 | 
						|
        xorl    %ebp,%ebp
 | 
						|
 | 
						|
	call _main
 | 
						|
	pushl %eax
 | 
						|
	jmp  _haltproc
 | 
						|
 | 
						|
.p2align 2,0x90
 | 
						|
.globl _haltproc
 | 
						|
.type _haltproc,@function
 | 
						|
 | 
						|
_haltproc:
 | 
						|
           mov $1,%eax
 | 
						|
           movzwl U_SYSTEM_EXITCODE,%ebx
 | 
						|
           pushl %ebx
 | 
						|
           call _actualsyscall
 | 
						|
           addl  $4,%esp
 | 
						|
           jmp   _haltproc
 | 
						|
 | 
						|
_actualsyscall:
 | 
						|
         int $0x80
 | 
						|
         jb .LErrorcode
 | 
						|
         xor %ebx,%ebx
 | 
						|
         ret
 | 
						|
.LErrorcode:
 | 
						|
         mov %eax,%ebx
 | 
						|
         mov $-1,%eax
 | 
						|
         ret
 | 
						|
        .p2align 2,0x90
 | 
						|
 | 
						|
# This section is needed for NetBSD to recognize a NetBSD binary as such.
 | 
						|
# otherwise it will be startup in Linux emulation mode.
 | 
						|
 | 
						|
.section ".note.netbsd.ident","a"
 | 
						|
.p2align 2
 | 
						|
 | 
						|
.long 7
 | 
						|
.long 4
 | 
						|
# ELF NOTE TYPE NETBSD TAG
 | 
						|
.long 1
 | 
						|
.ascii "NetBSD\0\0"
 | 
						|
.long 199905
 |