source: trunk/libs/newlib/src/libgloss/i386/cygmon-crt0.S @ 608

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

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

File size: 1.7 KB
RevLine 
[444]1/*
2 * crt0 startup code for user programs running under Cygmon
3 *
4 * Copyright (c) 1998, 2000 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#define _S2(P,X) P ## X
18#define _S1(P,X) _S2(P,X)
19#define SYM(X) _S1(__USER_LABEL_PREFIX__,X)
20
21.data
22        .align  8
23SYM(environ):
24        .long   0
25
26SYM(argc):
27        .long   0
28
29        .text
30        .align 4
31
32        .globl __start
33__start:
34        /* see if the stack is already setup. if not, then default
35         *  to using the value of %sp as set by the ROM monitor
36         */
37        movl    $__stack, %eax
38        testl   %eax, %eax
39        jz      1f
40        movl    %eax, %esp
411:
42        mov $0, %ebp
43
44        movl    $__bss_start, %edi
45        movl    $__bss_end, %ecx
46        subl    %edi, %ecx
47        xorl    %eax, %eax
48        rep; stosb
49
50        pushl   $SYM(__sigtramp)
51        pushl   $0
52        call    SYM(__install_signal_handler)
53        popl    %eax
54
55        pushl   $SYM(__do_global_dtors)
56        call    SYM(atexit)
57        popl    %eax
58
59        call    SYM(__do_global_ctors)
60
61        pushl   $SYM(argc)
62        call    SYM(__get_program_arguments)
63        popl    %ecx
64
65        movl    SYM(argc), %ecx
66        pushl   %eax
67        pushl   %ecx
68        call    SYM(main)
69        popl    %ecx
70        popl    %edx
71
72        /* call exit from the C library so atexit gets called, and the
73         * C++ destructors get run. This calls our exit routine below   
74         * when it's done.
75         */
76        pushl   %eax
77        call    SYM(exit)
783:
79        jmp     3b
Note: See TracBrowser for help on using the repository browser.