source: trunk/libs/newlib/src/libgloss/microblaze/crtinit.S @ 487

Last change on this file since 487 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.9 KB
Line 
1/* Copyright (c) 2001, 2009 Xilinx, Inc.  All rights reserved.
2   
3   Redistribution and use in source and binary forms, with or without
4   modification, are permitted provided that the following conditions are
5   met:
6   
7   1.  Redistributions source code must retain the above copyright notice,
8   this list of conditions and the following disclaimer.
9   
10   2.  Redistributions in binary form must reproduce the above copyright
11   notice, this list of conditions and the following disclaimer in the
12   documentation and/or other materials provided with the distribution.
13   
14   3.  Neither the name of Xilinx nor the names of its contributors may be
15   used to endorse or promote products derived from this software without
16   specific prior written permission.
17   
18   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
19   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31        .globl _crtinit
32        .align 2
33        .ent _crtinit
34        .type _crtinit, @function
35_crtinit:
36        addi    r1, r1, -20                     /* Save Link register    */
37        swi     r15, r1, 0
38
39        addi    r6, r0, __sbss_start            /* clear SBSS */
40        addi    r7, r0, __sbss_end     
41        rsub    r18, r6, r7             
42        blei    r18, .Lendsbss
43
44.Lloopsbss:     
45        swi     r0, r6, 0
46        addi    r6, r6, 4
47        rsub    r18, r6, r7
48        bgti    r18, .Lloopsbss
49.Lendsbss:
50
51        addi    r6, r0, __bss_start             /* clear BSS */
52        addi    r7, r0, __bss_end               
53        rsub    r18, r6, r7             
54        blei    r18, .Lendbss
55.Lloopbss:     
56        swi     r0, r6, 0
57        addi    r6, r6, 4
58        rsub    r18, r6, r7
59        bgti    r18, .Lloopbss
60.Lendbss:
61
62        brlid   r15, _program_init              /* Initialize the program  */
63        nop
64
65        brlid   r15, __init                     /* Invoke language initialization functions */
66        nop
67   
68        addi    r6, r0, 0                       /* Initialize argc = 1 and argv = NULL and envp = NULL  */
69        addi    r7, r0, 0                       
70        brlid   r15, main                       /* Execute the program */
71        addi    r5, r0, 0
72
73        addik   r19, r3, 0                      /* Save return value */
74   
75        brlid   r15, __fini                     /* Invoke language cleanup functions */
76        nop
77   
78        brlid   r15, _program_clean             /* Cleanup the program  */
79        nop
80
81        lw      r15, r1, r0                     /* Return back to CRT   */
82
83        addik   r3, r19, 0                      /* Restore return value */
84        rtsd    r15, 8
85        addi    r1, r1, 20
86        .end _crtinit
87
Note: See TracBrowser for help on using the repository browser.