source: trunk/libs/newlib/src/libgloss/sparc/erc32-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.8 KB
Line 
1/*
2 * This is based on the file srt0.s provided with the binary
3 * distribution of the SPARC Instruction Simulator (SIS) found
4 * at ftp://ftp.estec.esa.nl/pub/ws/wsd/erc32.
5 */
6
7#include "asm.h"
8
9        .register %g2, #scratch
10        .register %g3, #scratch
11
12        .data
13        .align  8
14SYM(environ):
15        .long   0
16
17        .text
18
19        .globl SYM(start)
20SYM(start):
21        sethi   %hi(__stack), %g1
22        or      %g1,%lo(__stack),%g1
23        mov     %g1, %sp                ! set the stack pointer
24        mov     %sp, %fp
25
26        /* clear the bss */
27        sethi %hi(__bss_start),%g2
28        or    %g2,%lo(__bss_start),%g2  ! start of bss
29        sethi %hi(_end),%g3
30        or    %g3,%lo(_end),%g3         ! end of bss
31        mov   %g0,%g1                   ! so std has two zeros
32zerobss:
33        std    %g0,[%g2]
34        add    %g2,8,%g2
35        cmp    %g2,%g3
36        bleu,a zerobss
37        nop
38
39        /* move data segment to proper location */
40 
41#if 0
42relocd:
43        set (_endtext),%g2              ! g2 = start of data in aout file
44        set (_environ),%g4              ! g4 = start of where data should go
45        set (_edata),%g3                ! g3 = end of where data should go
46        subcc   %g3, %g4, %g5           ! g5 = length of data
47
48        subcc   %g4, %g2, %g0           ! need to relocate data ?
49        ble     initok
50        ld      [%g4], %g6
51        subcc   %g6, 1, %g0
52        be      initok
53mvdata:
54        subcc   %g5, 8, %g5
55        ldd     [%g2 + %g5], %g6
56        bg      mvdata
57        std     %g6, [%g4 + %g5]
58
59initok:
60#endif
61
62        call    SYM(__fix_ctors)
63        nop
64        call    SYM(main)
65        nop
66
67        /* call exit from the C library so atexit gets called, and the
68         * C++ destructors get run. This calls our exit routine below    * when it's done.
69         */
70        call    SYM(exit)
71        nop
72
73        .globl  SYM(_exit)
74SYM(_exit):
75        set     0xdeadd00d, %o1         ! Magic number for simulator.
76        ta      0                       ! Halt if _main returns ...
77        nop
78 
Note: See TracBrowser for help on using the repository browser.