source: trunk/libs/newlib/src/libgloss/bfin/crt0.S @ 444

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

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

File size: 1.6 KB
Line 
1/*
2 * crt0.S for the Blackfin processor
3 *
4 * Copyright (C) 2006 Analog Devices, Inc.
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        .text
18        .align  2
19
20        .global __start
21__start:
22
23        /* Start by setting up a stack */
24        link 0xc;
25        /* Zero the memory in the .bss section.  */
26
27        p0.l = __edata;
28        p0.h = __edata;
29        p1.l = __end;
30        p1.h = __end;
31        p1 -= p0;
32        r0 = 0;
33        lsetup (L$L$clear_bss, L$L$clear_bss) lc0 = p1;
34L$L$clear_bss:
35        B [p0++] = r0;
36
37#ifdef __BFIN_FDPIC__
38        /* Set up GOT pointer.  */
39        P0.L = __ROFIXUP_END__;
40        P0.H = __ROFIXUP_END__;
41        P4 = [P0 - 4];
42#endif
43
44        /* Need to set up standard file handles */
45        /*  Parse string at r1 */
46
47        p0.l = __init;
48        p0.h = __init;
49        P3 = P4;
50        call    (p0)
51
52        p0.l = _atexit;
53        p0.h = _atexit;
54#ifdef __BFIN_FDPIC__
55        r0 = [P4 + __fini@FUNCDESC_GOT17M4];
56        P3 = P4;
57#else
58        r0.l = __fini;
59        r0.h = __fini;
60#endif
61        call    (p0)
62
63        p0.l = ___setup_argv_and_call_main;
64        p0.h = ___setup_argv_and_call_main;
65        P3 = P4;
66        call    (p0)
67
68        p0.l = _exit;
69        p0.h = _exit;
70        P3 = P4;
71        jump    (p0)            /* Should not return.  */
72        nop;
Note: See TracBrowser for help on using the repository browser.