summaryrefslogtreecommitdiff
path: root/rtl/linux/sparc/prt0.as
blob: 53f64a0e1f5af248e6fc665e62d2ab3134e4e681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#   $Id: prt0.as,v 1.9 2004/07/05 21:07:38 florian Exp $
/* Startup code for elf32-sparc
   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library 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.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

	.section ".text"
	.align 4
	.global _start
	.type _start,#function
_start:

  	/* Terminate the stack frame, and reserve space for functions to
     	   drop their arguments.  */
	mov	%g0, %fp
	sub	%sp, 6*4, %sp

  	/* Extract the arguments and environment as encoded on the stack.  The
     	   argument info starts after one register window (16 words) past the SP.  */
	ld	[%sp+22*4], %o2
	sethi	%hi(operatingsystem_parameter_argc),%o1
	or	%o1,%lo(operatingsystem_parameter_argc),%o1
	st	%o2, [%o1]

	add	%sp, 23*4, %o0
	sethi	%hi(operatingsystem_parameter_argv),%o1
	or	%o1,%lo(operatingsystem_parameter_argv),%o1
	st	%o0, [%o1]

	/* envp=(argc+1)*4+argv */
	inc     %o2
	sll     %o2, 2, %o2
	add	%o2, %o0, %o2
	sethi	%hi(operatingsystem_parameter_envp),%o1
	or	%o1,%lo(operatingsystem_parameter_envp),%o1
	st	%o2, [%o1]

  	/* Call the user program entry point.  */
  	call	PASCALMAIN
  	nop

.globl  _haltproc
.type   _haltproc,@function
_haltproc:
	mov	1, %g1			/* "exit" system call */
	sethi	%hi(operatingsystem_result),%o0
	or	%o0,%lo(operatingsystem_result),%o0
	ldsh	[%o0], %o0			/* give exit status to parent process*/
	ta	0x10			/* dot the system call */
	nop				/* delay slot */
	/* Die very horribly if exit returns.  */
	unimp

	.size _start, .-_start

        .comm operatingsystem_parameter_envp,4
        .comm operatingsystem_parameter_argc,4
        .comm operatingsystem_parameter_argv,4

#
# $Log: prt0.as,v $
# Revision 1.9  2004/07/05 21:07:38  florian
#   * remade makefile (too old fpcmake)
#   * fixed sparc startup code
#
# Revision 1.8  2004/07/03 21:50:31  daniel
#   * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
#     longer necessary
#
# Revision 1.7  2004/05/27 23:15:02  peter
#   * startup argc,argv,envp fix
#   * stat fixed
#
# Revision 1.6  2004/05/17 20:56:56  peter
#   * use ldsh to load exitcode
#
# Revision 1.5  2004/03/16 10:19:11  mazen
# + _haltproc definition for linux/sparc
#
# Revision 1.4  2003/06/02 22:03:37  mazen
# *making init and fini symbols compatible FPC code by
#  changing  _init ==> fpc_initialize
#  and _fini ==> fpc_finalize
#
# Revision 1.3  2002/11/18 19:03:46  mazen
# * start code of gcc adapted for FPC
#