annotate src/ecrt0.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 3ecd8885ac67
children 8b464283e891
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* C code startup routine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 428
diff changeset
24 /* [[The standard Vax 4.2 Unix crt0.c cannot be used for Emacs
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 because it makes `environ' an initialized variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 It is easiest to have a special crt0.c on all machines
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 428
diff changeset
27 though I don't know whether other machines actually need it.]]
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 428
diff changeset
28 This is insane! We DO NOT want to be doing this crap. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 /* On the vax and 68000, in BSD4.2 and USG5.2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 this is the data format on startup:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 (vax) ap and fp are unpredictable as far as I know; don't use them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 sp -> word containing argc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 word pointing to first arg string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 [word pointing to next arg string]... 0 or more times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Optionally:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 [word pointing to environment variable]... 1 or more times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 And always:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 first arg string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 [next arg string]... 0 or more times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 /* On the 16000, at least in the one 4.2 system I know about,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 the initial data format is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 sp -> word containing argc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 word containing argp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 word pointing to first arg string, and so on as above
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #define asm __asm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* Workaround for Sun cc 3.0, which doesn't handle asm's outside a fn. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #if __SUNPRO_C >= 0x300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #define no_toplevel_asm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 /* ******** WARNING ********
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 Do not insert any data definitions before data_start!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 Since this is the first file linked, the address of the following
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 variable should correspond to the start of initialized data space.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 On some systems this is a constant that is independent of the text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 size for shared executables. On others, it is a function of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 text size. In short, this seems to be the most portable way to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 discover the start of initialized data space dynamically at runtime,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 for either shared or unshared executables, on either swapping or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 virtual systems. It only requires that the linker allocate objects
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 in the order encountered, a reasonable model for most Unix systems.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 Similarly, note that the address of _start() should be the start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 of text space. Fred Fish, UniSoft Systems Inc. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 int data_start = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #ifdef NEED_ERRNO
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 int errno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #ifndef DONT_NEED_ENVIRON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 char **environ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #ifndef static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 /* On systems where the static storage class is usable, this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 should be declared as static. Otherwise, the static keyword has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 been defined to be something else, and code for those systems must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 take care of this declaration appropriately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 static start1 ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #ifdef APOLLO
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 extern char *malloc(), *realloc(), *(*_libc_malloc) (), *(*_libc_realloc)();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 extern void free(), (*_libc_free) (); extern int main();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 std_$call void unix_$main();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 _start()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 _libc_malloc = malloc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 _libc_realloc = realloc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 _libc_free = free;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 unix_$main(main); /* no return */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #endif /* APOLLO */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 #if defined(orion) || defined(pyramid) || defined(celerity) || defined(ALLIANT) || defined(clipper) || defined(sps7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 #if defined(sps7) && defined(V3x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 asm(" section 10");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 asm(" ds.b 0xb0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #ifdef ALLIANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 /* _start must initialize _curbrk and _minbrk on the first startup;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 when starting up after dumping, it must initialize them to what they were
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 before the dumping, since they are in the shared library and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 are not dumped. See ADJUST_EXEC_HEADER in m-alliant.h. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 extern unsigned char *_curbrk, *_minbrk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 extern unsigned char end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 unsigned char *_setbrk = &end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 #ifdef ALLIANT_2800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 unsigned char *_end = &end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 #ifndef DUMMIES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 #define DUMMIES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 _start (DUMMIES argc, argv, envp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 char **argv, **envp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 #ifdef ALLIANT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 #ifdef ALLIANT_2800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 _curbrk = _end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 _minbrk = _end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 _curbrk = _setbrk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 _minbrk = _setbrk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 environ = envp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 exit (main (argc, argv, envp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 #endif /* orion or pyramid or celerity or alliant or clipper */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #if defined (ns16000) && !defined (sequent) && !defined (UMAX) && !defined (CRT0_DUMMIES)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 _start ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* On 16000, _start pushes fp onto stack */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 start1 ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 /* ignore takes care of skipping the fp value pushed in start. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 start1 (ignore, argc, argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 int ignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 char **argv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 environ = argv + argc + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 if (environ == *argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 environ--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 exit (main (argc, argv, environ));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 #endif /* ns16000, not sequent and not UMAX, and not the CRT0_DUMMIES method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 #ifdef UMAX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 _start()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 asm(" exit [] # undo enter");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 asm(" .set exitsc,1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 asm(" .set sigcatchall,0x400");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 asm(" .globl _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 asm(" .globl start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 asm(" .globl __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 asm(" .globl _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 asm(" .globl _environ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 asm(" .globl _sigvec");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 asm(" .globl sigentry");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 asm("start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 asm(" br .xstart");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 asm(" .org 0x20");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 asm(" .double p_glbl,0,0xf00000,0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 asm(" .org 0x30");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 asm(".xstart:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 asm(" adjspb $8");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 asm(" movd 8(sp),0(sp) # argc");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 asm(" addr 12(sp),r0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 asm(" movd r0,4(sp) # argv");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 asm("L1:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 asm(" movd r0,r1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 asm(" addqd $4,r0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 asm(" cmpqd $0,0(r1) # null args term ?");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 asm(" bne L1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 asm(" cmpd r0,0(4(sp)) # end of 'env' or 'argv' ?");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 asm(" blt L2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 asm(" addqd $-4,r0 # envp's are in list");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 asm("L2:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 asm(" movd r0,8(sp) # env");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 asm(" movd r0,@_environ # indir is 0 if no env ; not 0 if env");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 asm(" movqd $0,tos # setup intermediate signal handler");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 asm(" addr @sv,tos");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 asm(" movzwd $sigcatchall,tos");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 asm(" jsr @_sigvec");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 asm(" adjspb $-12");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 asm(" jsr @_main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 asm(" adjspb $-12");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 asm(" movd r0,tos");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 asm(" jsr @_exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 asm(" adjspb $-4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 asm(" addr @exitsc,r0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 asm(" svc");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 asm(" .align 4 # sigvec arg");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 asm("sv:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 asm(" .double sigentry");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 asm(" .double 0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 asm(" .double 0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 asm(" .comm p_glbl,1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 #endif /* UMAX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 #ifdef CRT0_DUMMIES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /* Define symbol "start": here; some systems want that symbol. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 #ifdef DOT_GLOBAL_START
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 asm(" .text ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 asm(" .globl start ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 asm(" start: ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 #endif /* DOT_GLOBAL_START */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 #ifdef NODOT_GLOBAL_START
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 asm(" text ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 asm(" global start ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 asm(" start: ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 #endif /* NODOT_GLOBAL_START */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 #ifdef m68000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 /* GCC 2.1, when optimization is turned off, seems to want to push a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 word of garbage on the stack, which screws up the CRT0_DUMMIES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 hack. So we hand-code _start in assembly language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 asm(".text ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 #ifndef sony_news
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 asm(" .even ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 #else /* sony_news (not gas) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 + asm(" .align 2 ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 #endif /* sony_news (not gas) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 asm(".globl __start ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 asm("__start: ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 asm(" link a6,#0 ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 asm(" jbsr _start1 ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 asm(" unlk a6 ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 asm(" rts ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 #else /* not m68000 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 _start ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 /* On vax, nothing is pushed here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 /* On sequent, bogus fp is pushed here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 start1 ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 #endif /* possibly m68000 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #ifdef __bsdi__ /* for version number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 #include <sys/param.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 char *__progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 start1 (CRT0_DUMMIES int argc, char *xargv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 char **argv = &xargv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 environ = argv + argc + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 __progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 if ((char *)environ == xargv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 environ--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 exit (main (argc, argv, environ));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /* Refer to `start1' so GCC will not think it is never called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 and optimize it out. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (void) &start1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 #else /* not CRT0_DUMMIES */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 /* "m68k" and "m68000" both stand for m68000 processors,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 but with different program-entry conventions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 This is a kludge. Now that the CRT0_DUMMIES mechanism above exists,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 most of these machines could use the vax code above
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 with some suitable definition of CRT0_DUMMIES.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 Then the symbol m68k could be flushed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 But I don't want to risk breaking these machines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 in a version 17 patch release, so that change is being put off. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 #ifdef m68k /* Can't do it all from C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 asm (" global _start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 asm (" text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 asm ("_start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 #ifndef NU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 #ifdef STRIDE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 asm (" comm havefpu%,2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 #else /* m68k, not STRIDE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 asm (" comm splimit%,4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 #endif /* STRIDE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 asm (" global exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 asm (" text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 #ifdef STRIDE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 asm (" trap &3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 asm (" mov.w %d0,havefpu%");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 #else /* m68k, not STRIDE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 asm (" mov.l %d0,splimit%");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 #endif /* STRIDE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 #endif /* not NU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 asm (" jsr start1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 asm (" mov.l %d0,(%sp)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 asm (" jsr exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 asm (" mov.l &1,%d0"); /* d0 = 1 => exit */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 asm (" trap &0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 #else /* m68000, not m68k */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 #ifdef m68000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 #ifdef ISI68K
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* Added by ESM Sun May 24 12:44:02 1987 to get new ISI library to work */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* Edited by Ray Mon May 15 15:59:56 EST 1989 so we can compile with gcc */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 #if defined(BSD4_3) && !defined(__GNUC__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 static foo () {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 asm (" .globl is68020");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 asm ("is68020:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 #ifndef BSD4_3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 asm (" .long 0x00000000");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 asm (" .long 0xffffffff");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 /* End of stuff added by ESM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 asm (" .text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 asm (" .globl __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 asm ("__start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 asm (" .word 0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 asm (" link a6,#0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 asm (" jbsr _start1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 asm (" unlk a6");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 asm (" rts");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 #if defined(BSD4_3) && !defined(__GNUC__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 #else /* not ISI68K */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 _start ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 #ifdef sun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 #ifdef LISP_FLOAT_TYPE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 finitfp_();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* On 68000, _start pushes a6 onto stack */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 start1 ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 #endif /* not ISI68k */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 #endif /* m68000 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 #endif /* m68k */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 #if defined(m68k) || defined(m68000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 /* ignore takes care of skipping the a6 value pushed in start. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 #if defined(m68k)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 start1 (argc, xargv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 start1 (ignore, argc, xargv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 char *xargv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 char **argv = &xargv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 environ = argv + argc + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 if ((char *)environ == xargv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 environ--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 #ifdef sun_68881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 asm(" jsr f68881_used");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 #ifdef sun_fpa
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 asm(" jsr ffpa_used");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 #ifdef sun_soft
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 asm(" jsr start_float");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 exit (main (argc, argv, environ));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 #endif /* m68k or m68000 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 #endif /* not CRT0_DUMMIES */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 #ifdef hp9000s300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 int argc_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 char **argv_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 #ifdef OLD_HP_ASSEMBLER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 asm(" text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 asm(" globl __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 asm(" globl _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 asm(" globl _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 asm("__start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 asm(" dc.l 0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 asm(" subq.w #0x1,d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 asm(" move.w d0,float_soft");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 asm(" move.l 0x4(a7),d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 asm(" beq.s skip_1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 asm(" move.l d0,a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 asm(" clr.l -0x4(a0)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 asm("skip_1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 asm(" move.l a7,a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 asm(" subq.l #0x8,a7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 asm(" move.l (a0),(a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 asm(" move.l (a0),_argc_value");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 asm(" addq.l #0x4,a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 asm(" move.l a0,0x4(a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 asm(" move.l a0,_argv_value");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 asm("incr_loop");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 asm(" tst.l (a0)+");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 asm(" bne.s incr_loop");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 asm(" move.l 0x4(a7),a1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 asm(" cmp.l (a1),a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 asm(" blt.s skip_2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 asm(" subq.l #0x4,a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 asm("skip_2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 asm(" move.l a0,0x8(a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 asm(" move.l a0,_environ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 asm(" jsr _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 asm(" addq.l #0x8,a7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 asm(" move.l d0,-(a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 asm(" jsr _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 asm(" move.w #0x1,d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 asm(" trap #0x0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 asm(" comm float_soft,4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /* float_soft is allocated in this way because C would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 put an underscore character in its name otherwise. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 #else /* new hp assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 asm(" text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 asm(" global float_loc");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 asm(" set float_loc,0xFFFFB000");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 asm(" global fpa_loc");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 asm(" set fpa_loc,0xfff08000");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 asm(" global __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 asm(" global _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 asm(" global _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 asm("__start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 asm(" byte 0,0,0,0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 asm(" subq.w &1,%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 asm(" mov.w %d0,float_soft");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 asm(" mov.w %d1,flag_68881");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 #ifndef HPUX_68010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 asm(" beq.b skip_float");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 asm(" fmov.l &0x7400,%fpcr");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 /* asm(" fmov.l &0x7480,%fpcr"); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 #endif /* HPUX_68010 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 asm("skip_float:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 asm(" mov.l %a0,%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 asm(" add.l %d0,%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 asm(" subx.w %d1,%d1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 asm(" mov.w %d1,flag_68010");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 asm(" add.l %d0,%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 asm(" subx.w %d1,%d1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 asm(" mov.w %d1,flag_fpa");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 asm(" tst.l %d2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 asm(" ble.b skip_3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 asm(" lsl flag_68881");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 asm(" lsl flag_fpa");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 asm("skip_3:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 asm(" mov.l 4(%a7),%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 asm(" beq.b skip_1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 asm(" mov.l %d0,%a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 asm(" clr.l -4(%a0)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 asm("skip_1:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 asm(" mov.l %a7,%a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 asm(" subq.l &8,%a7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 asm(" mov.l (%a0),(%a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 asm(" mov.l (%a0),_argc_value");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 asm(" addq.l &4,%a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 asm(" mov.l %a0,4(%a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 asm(" mov.l %a0,_argv_value");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 asm("incr_loop:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 asm(" tst.l (%a0)+");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 asm(" bne.b incr_loop");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 asm(" mov.l 4(%a7),%a1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 asm(" cmp.l %a0,(%a1)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 asm(" blt.b skip_2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 asm(" subq.l &4,%a0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 asm("skip_2:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 asm(" mov.l %a0,8(%a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 asm(" mov.l %a0,_environ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 asm(" jsr _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 asm(" addq.l &8,%a7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 asm(" mov.l %d0,-(%a7)");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 asm(" jsr _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 asm(" mov.w &1,%d0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 asm(" trap &0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 asm(" comm float_soft, 4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 asm(" comm flag_68881, 4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 asm(" comm flag_68010, 4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 asm(" comm flag_68040, 4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 asm(" comm flag_fpa, 4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 #endif /* new hp assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 #endif /* hp9000s300 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 #ifdef GOULD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 /* startup code has to be in near text rather
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 than fartext as allocated by the C compiler. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 asm(" .text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 asm(" .align 2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 asm(" .globl __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 asm(" .text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 asm("__start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 /* setup base register b1 (function base). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 asm(" .using b1,.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 asm(" tpcbr b1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 /* setup base registers b3 through b7 (data references). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 asm(" file basevals,b3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 /* setup base register b2 (stack pointer); it should be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 aligned on a 8-word boundary; but because it is pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 to argc, its value should be remembered (in r5). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 asm(" movw b2,r4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 asm(" movw b2,r5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 asm(" andw #~0x1f,r4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 asm(" movw r4,b2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 /* allocate stack frame to do some work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 asm(" subea 16w,b2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 /* initialize signal catching for UTX/32 1.2; this is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 necessary to make restart from saved image work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 asm(" movea sigcatch,r1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 asm(" movw r1,8w[b2]");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 asm(" svc #1,#150");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 /* setup address of argc for start1. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 asm(" movw r5,8w[b2]");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 asm(" func #1,_start1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 asm(" halt");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 /* space for ld to store base register initial values. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 asm(" .align 5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 asm("basevals:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 asm(" .word __base3,__base4,__base5,__base6,__base7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 start1 (xargc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 int *xargc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 char **argv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 argc = *xargc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 argv = (char **)(xargc) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 environ = argv + argc + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 if (environ == argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 environ--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 exit (main (argc, argv, environ));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 #endif /* GOULD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 #ifdef elxsi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 #include <elxsi/argvcache.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 extern char **environ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 extern int errno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 extern void _init_doscan(), _init_iob();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 extern char end[];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 char *_init_brk = end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 _start()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 environ = exec_cache.ac_envp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 brk (_init_brk);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 errno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 _init_doscan ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 _init_iob ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 _exit (exit (main (exec_cache.ac_argc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 exec_cache.ac_argv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 exec_cache.ac_envp)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 #endif /* elxsi */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 #ifdef sparc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 #ifdef no_toplevel_asm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 static no_toplevel_asm_wrapper() {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 #ifdef USG5_4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 asm (".pushsection \".text\"");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 #endif /* USG5_4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 #endif /* no_toplevel_asm */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 #ifdef USG5_4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 asm (".global _start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 asm (".text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 asm ("_start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 asm (" mov 0, %fp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 asm (" ld [%sp + 64], %o0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 asm (" add %sp, 68, %o1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 asm (" sll %o0, 2, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 asm (" add %o2, 4, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 asm (" add %o1, %o2, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 asm (" sethi %hi(_environ), %o3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 asm (" st %o2, [%o3+%lo(_environ)]");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 asm (" andn %sp, 7, %sp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 asm (" call main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 asm (" sub %sp, 24, %sp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 asm (" call _exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 asm (" nop");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 asm (".global __start");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 asm (".text");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 asm ("__start:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 asm (" mov 0, %fp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 asm (" ld [%sp + 64], %o0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 asm (" add %sp, 68, %o1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 asm (" sll %o0, 2, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 asm (" add %o2, 4, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 asm (" add %o1, %o2, %o2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 asm (" sethi %hi(_environ), %o3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 asm (" st %o2, [%o3+%lo(_environ)]");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 asm (" andn %sp, 7, %sp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 asm (" call _main");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 asm (" sub %sp, 24, %sp");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 asm (" call __exit");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 asm (" nop");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 #endif /* USG5_4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 #ifdef no_toplevel_asm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 #ifdef USG5_4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 asm (".popsection");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 #endif /* USG5_4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 } /* no_toplevel_asm_wrapper() */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 #endif /* no_toplevel_asm */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 #endif /* sparc */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 #if __FreeBSD__ == 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 char *__progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 #ifdef __bsdi__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 #include <sys/param.h> /* for version number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 char *__progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 #endif /* __bsdi__ */