source: trunk/libs/newlib/src/libgloss/pa/crt0.S @ 546

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

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

File size: 2.7 KB
Line 
1/* crt0.S -- startup file for hppa.
2 *
3 * Copyright (c) 1995 Cygnus Support
4 *
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
13 * they apply.
14 */
15        .VERSION "1.0"
16        .COPYRIGHT "crt0.o for the PA"
17
18        .DATA
19
20/*
21 * Set up the standard spaces (sections) These definitions come
22 * from /lib/pcc_prefix.s.
23 */
24        .TEXT
25       
26/*
27 * stuff we need that's defined elsewhere.
28 */
29        .IMPORT main, CODE
30        .IMPORT exit, CODE
31        .IMPORT _bss_start, DATA
32        .IMPORT _end, DATA
33        .IMPORT environ, DATA
34
35/*
36 * start -- set things up so the application will run.
37 *
38 */
39        .PROC
40        .CALLINFO SAVE_SP, FRAME=48
41        .EXPORT $START$,ENTRY
42$START$
43
44        /* FIXME: this writes to page zero */
45        ;; setup the %30 (stack pointer) with some memory
46        ldil    L%_stack,%r30
47        ldo     R%_stack(%r30),%r30
48
49        ;; we need to set %r27 (global data pointer) here too
50        ldil    L%$global$,%r27
51        ldo     R%$global$(%r27),%r27           ; same problem as above
52
53/*
54 * zerobss -- zero out the bss section
55 */
56        ; load the start of bss
57        ldil    L%_bss_start,%r4
58        ldo     R%_bss_start(%r4),%r4
59
60        ;  load the end of bss
61        ldil    L%_end,%r5
62        ldo     R%_end(%r5),%r5
63
64
65L$bssloop
66        addi    -1,%r5,%r5                      ; decrement _bss_end
67        stb     %r0,0(0,%r5)                    ; we do this by bytes for now even
68                                                ; though it's slower, it's safer
69        combf,= %r4,%r5, L$bssloop     
70        nop
71       
72        ldi     1,%ret0
73
74/*
75 * Call the main routine from the application to get it going.
76 * main (argc, argv, environ)
77 * We pass argv as a pointer to NULL.
78 */
79
80        ldil    L%main,%r22
81        ble     R%main(%sr4,%r22)
82        copy    %r31,%r2
83/*
84 * Call exit() from the C library with the return value from main()
85 */
86        copy    %r28,%r26
87        ldil    L%exit,%r22
88        ble     R%exit(%sr4,%r22)
89        copy    %r31,%r2
90
91        .PROCEND
92/*
93 * _exit -- Exit from the application. Normally we cause a user trap
94 *          to return to the ROM monitor for another run.
95 */
96        .EXPORT _exit, ENTRY
97_exit
98        .PROC
99        .CALLINFO
100        .ENTRY
101       
102        ;; This just causes a breakpoint exception
103        break   0x0,0x0
104        bv,n    (%rp)
105        nop
106        .EXIT
107        .PROCEND
108
109/*
110 * _sr4export -- support for called functions. (mostly for GDB)
111 */
112        .EXPORT _sr4export, ENTRY
113_sr4export:
114        .PROC
115        .CALLINFO
116        .ENTRY
117
118        ble     0(%sr4,%r22)
119        copy    %r31,%rp
120        ldw     -24(%sr0,%sp),%rp
121        ldsid   (%sr0,%rp),%r1
122        mtsp    %r1,%sr0
123        be,n    0(%sr0,%rp)
124        nop
125        .EXIT
126        .PROCEND
127
128
Note: See TracBrowser for help on using the repository browser.