OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [mmix/] [crti.asm] - Blame information for rev 290

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
2
   Contributed by Hans-Peter Nilsson 
3
 
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
7
later version.
8
 
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.
13
 
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.
17
 
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
.  */
22
 
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.
27
 
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.
33
 
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
36
% segments.
37
 
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.
41
 
42
        .data   ! mmixal:= 8H LOC Data_Segment
43
        .p2align 3
44
        LOC @+(8-@)@7
45
        OCTA 2009
46
 
47
        .text   ! mmixal:= 9H LOC 8B; LOC #100
48
        .global Main
49
 
50
% The __Stack_start symbol is provided by the link script.
51
stackpp OCTA __Stack_start
52
 
53
% "Main" is the magic symbol the simulator jumps to.  We want to go
54
% on to "main".
55
% We need to set rG explicitly to avoid hard-to-debug situations.
56
Main    SETL    $255,32
57
        PUT     rG,$255
58
 
59
% Initialize the stack pointer.  It is supposedly made a global
60
% zero-initialized (allowed to change) register in crtn.asm; we use the
61
% explicit number.
62
        GETA    $255,stackpp
63
        LDOU    $254,$255,0
64
 
65
% Make sure we get more than one mem, to simplify counting cycles.
66
        LDBU    $255,$1,0
67
        LDBU    $255,$1,1
68
 
69
        PUSHJ   $2,_init
70
 
71
#ifdef __MMIX_ABI_GNU__
72
% Copy argc and argv from their initial position to argument registers
73
% where necessary.
74
        SET     $231,$0
75
        SET     $232,$1
76
#else
77
% For the mmixware ABI, we need to move arguments.  The return value will
78
% appear in $0.
79
        SET     $2,$1
80
        SET     $1,$0
81
#endif
82
 
83
        PUSHJ   $0,main
84
        JMP     exit
85
 
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.
91
 
92
        .section .init,"ax",@progbits
93
        .global _init
94
_init:
95
        GET     $0,:rJ
96
        PUSHJ   $1,0F
97
        SETL    $255,255
98
        TRAP    0,0,0
99
0H      IS      @
100
 
101
% Register _fini to be executed as the last atexit function.
102
#ifdef __MMIX_ABI_GNU__
103
        GETA    $231,_fini
104
#else
105
        GETA    $1,_fini
106
#endif
107
        PUSHJ   $0,atexit
108
 
109
        .section .fini,"ax",@progbits
110
        .global _fini
111
_fini:
112
        GET     $0,:rJ
113
        PUSHJ   $1,0F
114
        SETL    $255,255
115
        TRAP    0,0,0
116
0H      IS      @

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.