OSDN Git Service

update jelly sample (MIPS)
[hos/hos-v4a.git] / aplfw / sample / mips / jelly / gcc / crt0.S
1 /* ------------------------------------------------------------------------ */
2 /*  Hyper Operating System V4 Advance                                       */
3 /*    Sample program for Jelly                                              */
4 /*                                                                          */
5 /*                                  Copyright (C) 2008 by Project HOS       */
6 /*                                  http://sourceforge.jp/projects/hos/     */
7 /* ------------------------------------------------------------------------ */
8
9
10                                 .extern         _kernel_int_isp
11                                 .extern         _kernel_exc_hdr
12                                 .extern         ___data
13                                 .extern         ___data_end
14                                 .extern         ___data_rom
15                                 .extern         ___bss
16                                 .extern         ___bss_end
17                                 .extern         _gp
18                                 .extern         main
19
20                                 .global         _reset_handler
21                                 .global         _exception_handler
22
23
24
25                                 .text
26                                 .set    noreorder
27
28
29 /************************************************
30   %jp{リセットハンドラ}
31 ************************************************/
32                                 .ent    _reset_handler
33 _reset_handler: 
34                                 nop
35                                 nop
36                                 
37                                 la              $gp, _gp
38                                 la              $8, _kernel_int_isp
39                                 lw              $sp, 0($8)
40                                 
41                                 
42                                 // BSS initialize
43                                 la              $8, ___bss
44                                 la              $9, ___bss_end
45                                 beq             $8, $9, bss_loop_end
46                                 nop
47                                 
48 bss_loop:               
49                                 sw              $0, ($8)
50                                 addi    $8, $8, 4
51                                 bne             $8, $9, bss_loop
52                                 nop
53 bss_loop_end:   
54                                 
55                                 
56                                 // DATA copy
57                                 la              $8, ___data
58                                 la              $9, ___data_end
59                                 la              $10, ___data_rom
60                                 beq             $8, $9, data_loop_end
61                                 nop
62                                 
63 data_loop:              
64                                 lw              $11, ($10)
65                                 addi    $10, $10, 4
66                                 sw              $11, ($8)
67                                 addi    $8, $8, 4
68                                 bne             $8, $9, data_loop
69                                 nop
70 data_loop_end:  
71                                 
72                                 
73                                 la              $8, main
74                                 jal             $8
75                                 nop
76                                 j               _reset_handler
77                                 nop
78                                 
79                                 .end    _reset_handler
80
81
82
83 /************************************************
84   %jp{例外ハンドラ}
85 ************************************************/
86                                 .org    0x180
87                                 .ent    _exception_handler
88 _exception_handler:
89                                 la              $26, _kernel_exc_hdr
90                                 jr              $26
91                                 nop
92                                 
93                                 .end    _exception_handler
94
95
96
97 /* end of file */