1 |
38 |
julius |
/* Startup code for M68HC11.
|
2 |
|
|
Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is free software; you can redistribute it and/or modify it
|
5 |
|
|
under the terms of the GNU General Public License as published by the
|
6 |
|
|
Free Software Foundation; either version 2, or (at your option) any
|
7 |
|
|
later version.
|
8 |
|
|
|
9 |
|
|
In addition to the permissions in the GNU General Public License, the
|
10 |
|
|
Free Software Foundation gives you unlimited permission to link the
|
11 |
|
|
compiled version of this file with other programs, and to distribute
|
12 |
|
|
those programs without any restriction coming from the use of this
|
13 |
|
|
file. (The General Public License restrictions do apply in other
|
14 |
|
|
respects; for example, they cover modification of the file, and
|
15 |
|
|
distribution when not linked into another program.)
|
16 |
|
|
|
17 |
|
|
This file is distributed in the hope that it will be useful, but
|
18 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
|
|
General Public License for more details.
|
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU General Public License
|
23 |
|
|
along with this program; see the file COPYING. If not, write to
|
24 |
|
|
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
25 |
|
|
Boston, MA 02110-1301, USA. */
|
26 |
|
|
|
27 |
|
|
/* As a special exception, if you link this library with other files,
|
28 |
|
|
some of which are compiled with GCC, to produce an executable,
|
29 |
|
|
this library does not by itself cause the resulting executable
|
30 |
|
|
to be covered by the GNU General Public License.
|
31 |
|
|
This exception does not however invalidate any other reasons why
|
32 |
|
|
the executable file might be covered by the GNU General Public License. */
|
33 |
|
|
|
34 |
|
|
;-----------------------------------------
|
35 |
|
|
; startup code
|
36 |
|
|
;-----------------------------------------
|
37 |
|
|
.file "crt0.s"
|
38 |
|
|
|
39 |
|
|
#ifdef __HAVE_SHORT_INT__
|
40 |
|
|
.mode mshort
|
41 |
|
|
#else
|
42 |
|
|
.mode mlong
|
43 |
|
|
#endif
|
44 |
|
|
|
45 |
|
|
#if defined(__USE_RTC__) && defined(mc68hc12)
|
46 |
|
|
.macro jsr name
|
47 |
|
|
call \name
|
48 |
|
|
.endm
|
49 |
|
|
#endif
|
50 |
|
|
;;
|
51 |
|
|
;;
|
52 |
|
|
;; The linker concatenate the .install* sections in the following order:
|
53 |
|
|
;;
|
54 |
|
|
;; .install0 Setup the stack pointer
|
55 |
|
|
;; .install1 Place holder for applications
|
56 |
|
|
;; .install2 Optional installation of data section in memory
|
57 |
|
|
;; .install3 Place holder for applications
|
58 |
|
|
;; .install4 Invokes the main
|
59 |
|
|
;;
|
60 |
|
|
.sect .install0,"ax",@progbits
|
61 |
|
|
.globl _start
|
62 |
|
|
|
63 |
|
|
_start:
|
64 |
|
|
;;
|
65 |
|
|
;; At this step, the stack is not initialized and interrupts are masked.
|
66 |
|
|
;; Applications only have 64 cycles to initialize some registers.
|
67 |
|
|
;;
|
68 |
|
|
;; To have a generic/configurable startup, initialize the stack to
|
69 |
|
|
;; the end of some memory region. The _stack symbol is defined by
|
70 |
|
|
;; the linker.
|
71 |
|
|
;;
|
72 |
|
|
lds #_stack
|
73 |
|
|
|
74 |
|
|
.sect .install2,"ax",@progbits
|
75 |
|
|
;;
|
76 |
|
|
;; Call a specific initialization operation. The default is empty.
|
77 |
|
|
;; It can be overridden by applications. It is intended to initialize
|
78 |
|
|
;; the 68hc11 registers. Function prototype is:
|
79 |
|
|
;;
|
80 |
|
|
;; int __premain(void);
|
81 |
|
|
;;
|
82 |
|
|
jsr __premain
|
83 |
|
|
|
84 |
|
|
;;
|
85 |
|
|
;;
|
86 |
|
|
;;
|
87 |
|
|
.sect .install4,"ax",@progbits
|
88 |
|
|
jsr main
|
89 |
|
|
fatal:
|
90 |
|
|
jsr exit
|
91 |
|
|
bra fatal
|
92 |
|
|
|
93 |
|
|
;-----------------------------------------
|
94 |
|
|
; end startup code
|
95 |
|
|
;-----------------------------------------
|
96 |
|
|
;; Force loading of data section mapping and bss clear
|
97 |
|
|
.2byte __map_data_section
|
98 |
|
|
.2byte __init_bss_section
|