2 * crt0.S -- startup file for hppa.
3 * rob@cygnus.com (Rob Savoye)
6 .COPYRIGHT "crt0.S for hppa"
8 ;sp .equ %r30 ; stack pointer
9 ;dp .equ %r27 ; global data pointer
10 ;arg0 .equ %r26 ; argument
11 ;arg1 .equ %r25 ; argument or high part of double argument
12 ;arg2 .equ %r24 ; argument
13 ;arg3 .equ %r23 ; argument or high part of double argument
15 #define IMM(a,b) ldil L%a,b ! ldo R%a(b),b
16 #define imm(i,t) ldil LS%i,t ! addi RS%i,t,t
21 * FIXME: these are just a gross hack so this will assemble
26 .STRINGZ "Foo Bar...\r\n"
29 ;; .EXPORT _SYSTEM_ID ; FIXME this is only so it'll
33 * Set up the standard spaces (sections) These definitions come
34 * from /lib/pcc_prefix.s.
38 .SUBSPA $BOOT$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=4
42 * stuff we need that's defined elsewhere.
45 .IMPORT _bss_start, DATA
46 .IMPORT _bss_end, DATA
50 * start -- set things up so the application will run.
54 .CALLINFO SAVE_SP, FRAME=48
58 /* FIXME: this writes to page zero */
59 ;; setup the %30 (stack pointer) with some memory
61 ldo R%_stack+48(%r30),%r30 ; should be %r30 (sp) but then
62 ; we'd kill our test program :-)
63 ;; we need to set %r27 (global data pointer) here too
65 ldo R%$global$(%r27),%r27 ; same problem as above
68 * zerobss -- zero out the bss section
70 ; load the start of bss
72 ldo R%_bss_start(%r4),%r4
76 ldo R%_bss_end(%r5),%r5
80 addi -1,%r5,%r5 ; decrement _bss_end
81 stb %r0,0(0,%r5) ; we do this by bytes for now even
82 ; though it's slower, it's safer
83 combf,= %r4,%r5, bssloop
89 * Call the main routine from the application to get it going.
90 * main (argc, argv, environ)
91 * We pass argv as a pointer to NULL.
99 * _exit -- Exit from the application. Normally we cause a user trap
100 * to return to the ROM monitor for another run, but with
101 * this monitor we can't. Still, "C" wants this symbol, it
102 * should be here. Jumping to 0xF0000004 jumps back into the
103 * firmware, while writing a 5 to 0xFFFE0030 causes a reset.
110 ;; ldil L%0xf0000004,%r1
113 ldil L'4026531844,%r19
114 ldo R'4026531844(%r19),%r19
118 ;; This just causes a breakpoint exception
125 .subspa $UNWIND_START$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=56
126 .export $UNWIND_START
128 .subspa $UNWIND$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=64
129 .subspa $UNWIND_END$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=72
132 .subspa $RECOVER_START$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=73
133 .export $RECOVER_START
135 .subspa $RECOVER$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=80
136 .subspa $RECOVER_END$,QUAD=0,ALIGN=4,ACCESS=0x2c,SORT=88
140 ; The following declarations are, by default in the data space ($PRIVATE$)
142 ;; .space $PRIVATE$,1
145 * Here we set up the standard date sub spaces.
146 * _dp is for the WinBond board.
148 * Set up some room for a stack. We just grab a chunk of memory.
149 * We also setup some space for the global variable space, which
150 * must be done using the reserved name "$global$" so "C" code
151 * can find it. The stack grows towards the higher addresses.
154 .subspa $DATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=16
155 .subspa $SHORTDATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=24
156 .subspa $GLOBAL$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40
161 .subspa $SHORTBSS$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=80,ZERO
162 .subspa $BSS$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=82,ZERO
164 .subspa $STACK$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=88,ZERO
170 * The heap follows the stack. To use dynamic memory routines in an
171 * application, some space MUST be assigned to the stack.
174 .subspa $HEAP$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=96,ZERO