]> begriffs open source - cmsis-freertos/blob - Demo/H8S/RTOSDemo/start.asm
Update README.md - branch main is now the base branch
[cmsis-freertos] / Demo / H8S / RTOSDemo / start.asm
1 ;/****************************************************************
2 ;KPIT Cummins Infosystems Ltd, Pune, India. - 4th September 2003.
3 ;
4 ;This program is distributed in the hope that it will be useful,
5 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
6 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
7 ;
8 ;*****************************************************************/
9
10
11 ;*********************************************************************
12 ; File: start.asm
13 ;
14 ;
15 ; desc:
16
17 ;  System initialisation routine - entry point for the application.
18 ;  The stack pointer is initialised, then the hardware initialisation
19 ;  routine called.  The static data areas are then initialised, before
20 ;  the main function is executed.  A simple exit funtion is also
21 ;  supplied
22 ;
23 ;*********************************************************************
24
25 #ifdef __H8300H__  
26
27 #ifdef __NORMAL_MODE__
28         .h8300hn
29 #else
30         .h8300h
31 #endif
32
33 #endif  /*_H8300H_ */
34
35 #ifdef __H8300S__
36
37 #ifdef __NORMAL_MODE__
38         .h8300sn
39 #else
40         .h8300s
41 #endif
42
43 #endif /* __H8300S__ */
44         
45         .section .text
46         .global _start
47 #if DEBUG       
48         .extern _exit
49 #endif
50
51         .extern _hw_initialise
52         .extern _main
53
54         .extern _data
55         .extern _mdata
56         .extern _edata
57         .extern _bss
58         .extern _ebss
59         .extern _stack
60
61 _start:
62         ; initialise the SP for non-vectored code
63     mov.l   #_stack,er7
64         ; call the hardware initialiser
65         jsr     @_hw_initialise
66 #ifdef ROMSTART 
67         ; get the boundaries for the .data section initialisation
68     mov.l   #_data,er0
69     mov.l   #_edata,er1
70     mov.l   #_mdata,er2
71     cmp.l   er0,er1
72         beq     start_1
73 start_l:
74     mov.b   @er2,r3l  ;get from src
75     mov.b   r3l,@er0  ;place in dest
76     inc.l   #1,er2    ;inc src
77     inc.l   #1,er0    ;inc dest
78     cmp.l   er0,er1   ;dest == edata?
79         bne     start_l
80 start_1:
81 #endif          //ROMSTART
82         ; zero out bss
83     mov.l   #_bss,er0
84     mov.l   #_ebss,er1
85     cmp.l   er0,er1         
86         beq     start_3
87         sub.b   r2l,r2l
88 start_2:
89     mov.b   r2l,@er0
90     inc.l   #1,er0
91     cmp.l   er0,er1
92         bne     start_2
93 start_3:
94 #ifdef CPPAPP   
95         ;Initialize global constructor  
96         jsr     @___main
97 #endif
98         
99         ; call the mainline     
100         jsr     @_main
101
102         
103     mov.l   er0,er4
104     
105     ;call to exit
106 #if DEBUG
107     jsr     @_exit
108 #endif
109 #if RELEASE
110  exit:
111         bra     exit
112 #endif
113
114         
115