summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/H8S/RTOSDemo/start.asm
blob: be99b210895fccadb552aa62ff96e5c77d1caec7 (plain)
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
107
108
109
110
111
112
113
114
115
;/****************************************************************
;KPIT Cummins Infosystems Ltd, Pune, India. - 4th September 2003.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
;
;*****************************************************************/


;*********************************************************************
; File: start.asm
;
;
; desc:
; 
;  System initialisation routine - entry point for the application.
;  The stack pointer is initialised, then the hardware initialisation
;  routine called.  The static data areas are then initialised, before
;  the main function is executed.  A simple exit funtion is also
;  supplied
;
;*********************************************************************

#ifdef __H8300H__  

#ifdef __NORMAL_MODE__
	.h8300hn
#else
	.h8300h
#endif

#endif	/*_H8300H_ */

#ifdef __H8300S__

#ifdef __NORMAL_MODE__
	.h8300sn
#else
	.h8300s
#endif

#endif /* __H8300S__ */
	
	.section .text
	.global _start
#if DEBUG	
	.extern _exit
#endif

	.extern _hw_initialise
	.extern _main

	.extern _data
	.extern _mdata
	.extern _edata
	.extern _bss
	.extern _ebss
	.extern _stack

_start:
	; initialise the SP for non-vectored code
    mov.l   #_stack,er7
	; call the hardware initialiser
	jsr     @_hw_initialise
#ifdef ROMSTART	
	; get the boundaries for the .data section initialisation
    mov.l   #_data,er0
    mov.l   #_edata,er1
    mov.l   #_mdata,er2
    cmp.l   er0,er1
	beq     start_1
start_l:
    mov.b   @er2,r3l  ;get from src
    mov.b   r3l,@er0  ;place in dest
    inc.l   #1,er2    ;inc src
    inc.l   #1,er0    ;inc dest
    cmp.l   er0,er1   ;dest == edata?
	bne     start_l
start_1:
#endif		//ROMSTART
	; zero out bss
    mov.l   #_bss,er0
    mov.l   #_ebss,er1
    cmp.l   er0,er1         
	beq     start_3
	sub.b   r2l,r2l
start_2:
    mov.b   r2l,@er0
    inc.l   #1,er0
    cmp.l   er0,er1
	bne     start_2
start_3:
#ifdef CPPAPP	
	;Initialize global constructor	
	jsr	@___main
#endif
	
	; call the mainline     
	jsr     @_main

	
    mov.l   er0,er4
    
    ;call to exit
#if DEBUG
    jsr     @_exit
#endif
#if RELEASE
 exit:
	bra 	exit
#endif