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 2, or (at your option) any
9 In addition to the permissions
in the GNU General
Public License
, the
10 Free Software Foundation gives you unlimited permission to link the
11 compiled version of
this file
into combinations with other programs
,
12 and to distribute those combinations without any restriction coming
13 from the use of
this file.
(The General
Public License restrictions
14 do apply
in other respects
; for example, they cover modification of
15 the file
, and distribution when
not linked
into a combine
18 This file is distributed
in the hope that it will be useful
, but
19 WITHOUT ANY WARRANTY
; without even the implied warranty of
20 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General
Public License for more details.
23 You should have received a copy of the GNU General
Public License
24 along with
this program
; see the file COPYING. If not, write to
25 the Free Software Foundation
, 51 Franklin Street
, Fifth Floor
,
26 Boston
, MA
02110-1301, USA.
*/
28 % This is the crt0 equivalent for mmix
-knuth
-mmixware
, for setting up
29 % things for compiler
-generated assembly
-code
and for setting up things
30 % between where the simulator calls
and main
, and shutting things down on
31 % the way back. There
's an actual crt0.o elsewhere, but that's a dummy.
33 % This file
and the GCC output are supposed to be
*reasonably
*
34 % mmixal
-compatible to enable people to re
-use output with Knuth
's mmixal.
35 % However, forward references are used more freely: we are using the
36 % binutils tools. Users of mmixal beware; you will sometimes have to
37 % re-order things or use temporary variables.
39 % Users of mmixal will want to set up 8H and 9H to be .text and .data
40 % respectively, so the compiler can switch between them pretending they're
43 % This little treasure is here so the
32 lowest address bits of user data
44 % will
not be zero. Because of truncation
, that would cause testcase
45 % gcc.c
-torture
/execute
/980701-1.c to incorrectly fail.
47 .data
! mmixal:= 8H LOC Data_Segment
52 .text
! mmixal:= 9H LOC
8B; LOC #100
55 % The __Stack_start symbol is provided by the link script.
56 stackpp OCTA __Stack_start
58 % "Main" is the magic symbol the simulator jumps to. We want to go
60 % We need to set rG explicitly to avoid hard
-to
-debug situations.
64 % Initialize the stack pointer. It is supposedly made a
global
65 % zero
-initialized
(allowed to change
) register
in crtn.asm
; we use the
70 % Make sure we get more than one mem
, to simplify counting cycles.
76 #ifdef __MMIX_ABI_GNU__
77 % Copy argc
and argv from their initial position to argument registers
82 % For the mmixware ABI
, we need to move arguments. The return value will
91 % Provide the first part of _init
and _fini. Save the return address on the
92 % register stack. We eventually ignore the return address of these
93 % PUSHJ:s
, so it doesn
't matter that whether .init and .fini code calls
94 % functions or where they store rJ. We shouldn't get there
, so die
95 % (TRAP Halt
) if that happens.
97 .
section .init
,"ax",@progbits
106 % Register _fini to be executed as the last atexit function.
107 #ifdef __MMIX_ABI_GNU__
114 .
section .fini
,"ax",@progbits