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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [m68k/] [sim-crt0.S] - Blame information for rev 823

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * crt0.S -- startup file for m68k-coff
3
 *
4
 * Copyright (c) 1995, 1996, 1998, 2001 Cygnus Support
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 */
16
 
17
#include "asm.h"
18
 
19
        .title "crt0.S for m68k-coff"
20
#define STACKSIZE       0x4000
21
 
22
/*
23
 * Define an empty environment.
24
 */
25
        .data
26
        .align 2
27
SYM (environ):
28
        .long 0
29
 
30
        .align  2
31
        .text
32
 
33
/*
34
 * These symbols are defined in C code, so they need to always be
35
 * named with SYM because of the difference between object file formats.
36
 */
37
 
38
/* These are defined in C code. */
39
        .extern SYM (main)
40
        .extern SYM (exit)
41
        .extern SYM (atexit)
42
        .extern SYM(__do_global_dtors)
43
 
44
/*
45
 * These values are set in the linker script, so they must be
46
 * explicitly named here without SYM.
47
 */
48
        .extern __stack
49
        .extern __bss_start
50
        .extern _end
51
 
52
/*
53
 * set things up so the application will run. This *must* be called start.
54
 */
55
        .global SYM (start)
56
 
57
SYM (start):
58
        /* See if user supplied their own stack (__stack != 0).  If not, then
59
         * default to using the value of %sp as set by the ROM monitor.
60
         */
61
        movel   IMM(__stack), a0
62
        cmpl    IMM(0), a0
63
        jbeq    1f
64
        movel   a0, sp
65
1:
66
        /* set up initial stack frame */
67
        link    a6, IMM(-8)
68
 
69
/*
70
 * zero out the bss section.
71
 */
72
        movel   IMM(__bss_start), d1
73
        movel   IMM(_end), d0
74
        cmpl    d0, d1
75
        jbeq    3f
76
        movl    d1, a0
77
        subl    d1, d0
78
        subql   IMM(1), d0
79
2:
80
        clrb    (a0)+
81
#if !defined(__mcoldfire__) && !defined(__mcf5200__)
82
        dbra    d0, 2b
83
        clrw    d0
84
        subql   IMM(1), d0
85
        jbcc    2b
86
#else
87
        subql   IMM(1), d0
88
        jbpl    2b
89
#endif
90
 
91
3:
92
 
93
/*
94
 * call the main routine from the application to get it going.
95
 * main (argc, argv, environ)
96
 * we pass argv as a pointer to NULL.
97
 */
98
 
99
#ifdef ADD_DTORS
100
        /* put __do_global_dtors in the atexit list so the destructors get run */
101
        movel   IMM (SYM(__do_global_dtors)),(sp)
102
        PICCALL SYM (atexit)
103
#endif
104
        movel   IMM (__FINI_SECTION__),(sp)
105
        PICCALL SYM (atexit)
106
 
107
        PICCALL __INIT_SECTION__
108
 
109
        pea     0
110
        PICPEA  SYM (environ),a0
111
        pea     sp@(4)
112
        pea     0
113
        PICCALL SYM (main)
114
        movel   d0, sp@-
115
 
116
/*
117
 * drop down into exit incase the user doesn't. This should drop
118
 * control back to the ROM monitor, if there is one. This calls the
119
 * exit() from the C library so the C++ tables get cleaned up right.
120
 */
121
        PICCALL SYM (exit)

powered by: WebSVN 2.1.0

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