summaryrefslogtreecommitdiffstats
path: root/c/src/lib/start/i960/start.s
blob: f9287d26414dfc3a11da6c355842abf43c206a88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*  entry.s
 *
 *  This file contains the entry point for the application.
 *  The name of this entry point is compiler dependent.
 *  It jumps to the BSP which is responsible for performing
 *  all initialization.
 *
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
 *  On-Line Applications Research Corporation (OAR).
 *  All rights assigned to U.S. Government, 1994.
 *
 *  This material may be reproduced by or for the U.S. Government pursuant
 *  to the copyright license under the clause at DFARS 252.227-7013.  This
 *  notice must appear in all copies of this file and its derivatives.
 *
 *  $Id$
 */

#include "asm.h"

        BEGIN_CODE
        PUBLIC(start)                 # GNU960 default entry point

start:
        mov     3, r12
        modpc   r12, r12, r12         # enable tracing/trace faults
        mov     g5, g5                # NOP
        mov     0, g14                # initialize constant for C

        /*
         * zero out uninitialized data area
         */
zerobss:
        lda     _end, r4        /* find end of .bss */
        lda     _bss_start, r5  /* find beginning of .bss */
        ldconst 0, r6

loop:   st      r6, (r5)        /* to zero out uninitialized */
        addo    4, r5, r5       /* data area                 */
        cmpobl  r5, r4, loop    /* loop until _end reached   */

/* set up stack pointer:
 *   The heap will begin at '_end';  its length is 'heap_size'
 *   bytes.  The stack will begin at the first 64-byte-aligned
 *   block after the heap.
 *
 *   A default value of 'heap_size' is set by linking with libnindy.a
 *   The default can be overridden by redefining this symbol at link
 *   time (with a line of the form 'heap_size=XXXX;' in the lnk960
 *   linker specification file; or one of the form
 *   "-defsym heap_size=XXXX" on the gld960 invocation line).
 */

        ldconst _end, sp         /* set sp = address of end of heap */
        lda     heap_size(sp),sp
        lda     64(sp), sp       /* Now round up to 64-byte boundary */
        ldconst 0xffffffc0, r12
        and     r12, sp, sp
        st      sp, _stack_start /* Save for brk() routine */

        call    init_frames
        ret                      /* return to monitor */

init_frames:
        mov     0, g14           /* initialize constant for C */
        ldconst 0x3b001000, g0
        ldconst 0x00009107, g1
        modac   g1, g0, g0       /* set AC controls */

        /*
         * remember the frame, so that we can set it up if necessary
         */

        st      fp, _start_frame

        /*
         * Call application mainline.
         *      Someday, real values of argc and argv will be set up.
         *      For now, they are set to 0.
         */
        ldconst 0,g0
        ldconst 0,g1
        ldconst 0,g2
        call    _main
        ret

END_CODE

         BEGIN_DATA

        PUBLIC(_start_frame)
SYM (_start_frame):
        .word   0                  # addr of first user frame: for gdb960

SYM (_stack_start):
        PUBLIC(_stack_start)
        .word   0                  # addr of first user frame: for gdb960

END_DATA

BEGIN_BSS
        PUBLIC(heap_size)
        .set    heap_size,0x2000
END_BSS

END