1 /* Copyright
(C
) 2001, 2002 Free Software Foundation
, Inc.
2 Contributed by Hans
-Peter Nilsson
<hp
@bitrange.com
>
4 This file is free software
; you can redistribute it and/or modify it
5 under the terms of the GNU General
Public License as published by the
6 Free Software Foundation
; either version 3, or (at your option) any
9 This file is distributed
in the hope that it will be useful
, but
10 WITHOUT ANY WARRANTY
; without even the implied warranty of
11 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General
Public License for more details.
14 Under
Section 7 of GPL version
3, you are granted additional
15 permissions described
in the GCC Runtime Library Exception
, version
16 3.1, as published by the Free Software Foundation.
18 You should have received a copy of the GNU General
Public License
and
19 a copy of the GCC Runtime Library Exception along with
this program
;
20 see the files COPYING3
and COPYING.RUNTIME respectively. If
not, see
21 <http://www.gnu.
org/licenses
/>.
*/
23 % This is the crt0 equivalent for mmix
-knuth
-mmixware
, for setting up
24 % things for compiler
-generated assembly
-code
and for setting up things
25 % between where the simulator calls
and main
, and shutting things down on
26 % the way back. There
's an actual crt0.o elsewhere, but that's a dummy.
28 % This file
and the GCC output are supposed to be
*reasonably
*
29 % mmixal
-compatible to enable people to re
-use output with Knuth
's mmixal.
30 % However, forward references are used more freely: we are using the
31 % binutils tools. Users of mmixal beware; you will sometimes have to
32 % re-order things or use temporary variables.
34 % Users of mmixal will want to set up 8H and 9H to be .text and .data
35 % respectively, so the compiler can switch between them pretending they're
38 % This little treasure is here so the
32 lowest address bits of user data
39 % will
not be zero. Because of truncation
, that would cause testcase
40 % gcc.c
-torture
/execute
/980701-1.c to incorrectly fail.
42 .data
! mmixal:= 8H LOC Data_Segment
47 .text
! mmixal:= 9H LOC
8B; LOC #100
50 % The __Stack_start symbol is provided by the link script.
51 stackpp OCTA __Stack_start
53 % "Main" is the magic symbol the simulator jumps to. We want to go
55 % We need to set rG explicitly to avoid hard
-to
-debug situations.
59 % Initialize the stack pointer. It is supposedly made a
global
60 % zero
-initialized
(allowed to change
) register
in crtn.asm
; we use the
65 % Make sure we get more than one mem
, to simplify counting cycles.
71 #ifdef __MMIX_ABI_GNU__
72 % Copy argc
and argv from their initial position to argument registers
77 % For the mmixware ABI
, we need to move arguments. The return value will
86 % Provide the first part of _init
and _fini. Save the return address on the
87 % register stack. We eventually ignore the return address of these
88 % PUSHJ:s
, so it doesn
't matter that whether .init and .fini code calls
89 % functions or where they store rJ. We shouldn't get there
, so die
90 % (TRAP Halt
) if that happens.
92 .
section .init
,"ax",@progbits
101 % Register _fini to be executed as the last atexit function.
102 #ifdef __MMIX_ABI_GNU__
109 .
section .fini
,"ax",@progbits