initial import
[glibc.git] / sysdeps / unix / bsd / Attic / osf1 / alpha / start.S
blob8b7109a5121a0d4a4b9cf56b4e7bfdee2b522e7f
1 /* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
2    Contributed by Brendan Kehoe (brendan@zen.org).
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB.  If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA.  */
19 #include <sysdep.h>
21 #ifndef HAVE_WEAK_SYMBOLS
22 #define __environ environ
23 #else
24 weak_alias (__environ, environ)
25 #endif
27 .comm __environ,        8
28 .comm errno,            4
30 !.sdata
31 !.globl STARTFRM
32 !STARTFRM = 0
34 .text
35 ENTRY(__start)
36         lda     sp, -16(sp)
37         stq     zero, 8(sp)
39         ! This branch puts the address of the current insn in t0.
40         br      t0, 10f
41 10:
42         ! We set the GP register by using the address of the ldgp
43         ! (what we just put into t0).
44         ldgp    gp, 0(t0)
46         ! get argc
47         ldl     a0, 16(sp)
49         ! get argv
50         lda     a1, 24(sp)
52         ! move ahead to envp
53         s8addq  a0, a1, a2
54         addq    a2, 0x8, a2
56         ! Store in environ.
57         stq     a2, environ
59         ! Clear out errno.
60 !       ldgp    gp, 0(t12)
61         stl     zero, errno
63         ! Call main.
64         jsr     ra, main
65         ldgp    gp, 0(ra)
67         mov     v0, a0
69         jsr     ra, exit
70         ldgp    gp, 0(ra)
72         .end __start