Skip to content

Commit 366f48b

Browse files
jdx-ghjjohnstn
authored andcommitted
newlib/ChangeLog:
* libc/sys/h8300hms/crt0.S: General cleanup: declare stack section in a proper way, merge H8/300H and H8/300S/SX parts of code into one, add support for normal mode.
1 parent 351842d commit 366f48b

File tree

1 file changed

+32
-48
lines changed
  • newlib/libc/sys/h8300hms

1 file changed

+32
-48
lines changed

newlib/libc/sys/h8300hms/crt0.S

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; h8/300 and h8/300h start up file.
1+
; H8/300, H8/300H, H8/300S and H8SX start up file.
22

33
#include "setarch.h"
44

@@ -10,90 +10,74 @@ _start:
1010
mov.w #_stack,sp
1111
mov.w #_edata,r0
1212
mov.w #_end,r2
13-
sub.w r1,r1
13+
sub.w r1,r1
1414
sub.w r0,r2
1515
jsr @_memset
1616
#ifdef __ELF__
17-
mov.l #__fini,r0
18-
jsr @_atexit
17+
mov.w #__fini,r0
18+
jsr @_atexit
1919
#ifdef __SIMULATOR__
20-
jsr @0xcc
20+
jsr @0xcc
2121
#endif
22-
jsr @__init
22+
jsr @__init
2323
#else
2424
#ifdef __SIMULATOR__
25-
jsr @0xcc
25+
jsr @0xcc
2626
#endif
2727
jsr @___main
2828
#endif
2929
jsr @_main
3030
jsr @_exit
3131

32-
.section .stack
33-
_stack: .word 1
32+
.section .stack, "aw", @nobits
33+
_stack: .space 2
3434

3535
#endif
3636

37-
#ifdef __H8300H__
37+
#if defined (__H8300H__) || defined (__H8300S__) || defined (__H8300SX__)
3838

3939
.section .text
4040
.global _start
4141
_start:
42+
#ifdef __NORMAL_MODE__
43+
mov.w #_stack,sp
44+
mov.w #_edata,r0
45+
mov.w #_end,r2
46+
sub.l er1,er1
47+
sub.w r0,r2
48+
#else
4249
mov.l #_stack,sp
4350
mov.l #_edata,er0
4451
mov.l #_end,er2
45-
sub.w r1,r1
52+
sub.l er1,er1
4653
sub.l er0,er2
54+
#endif
4755
jsr @_memset
4856
#ifdef __ELF__
49-
mov.l #__fini,er0
50-
jsr @_atexit
51-
#ifdef __SIMULATOR__
52-
jsr @0xcc
53-
#endif
54-
jsr @__init
57+
#ifdef __NORMAL_MODE__
58+
mov.w #__fini,r0
5559
#else
56-
#ifdef __SIMULATOR__
57-
jsr @0xcc
58-
#endif
59-
jsr @___main
60+
mov.l #__fini,er0
6061
#endif
61-
jsr @_main
62-
jsr @_exit
63-
64-
.section .stack
65-
_stack: .long 1
66-
67-
#endif
68-
69-
#if defined (__H8300S__) || defined (__H8300SX__)
70-
71-
.section .text
72-
.global _start
73-
_start:
74-
mov.l #_stack,sp
75-
mov.l #_edata,er0
76-
mov.l #_end,er2
77-
sub.w r1,r1
78-
sub.l er0,er2
79-
jsr @_memset
80-
#ifdef __ELF__
81-
mov.l #__fini,er0
82-
jsr @_atexit
62+
jsr @_atexit
8363
#ifdef __SIMULATOR__
84-
jsr @0xcc
64+
jsr @0xcc
8565
#endif
86-
jsr @__init
66+
jsr @__init
8767
#else
8868
#ifdef __SIMULATOR__
89-
jsr @0xcc
69+
jsr @0xcc
9070
#endif
9171
jsr @___main
9272
#endif
9373
jsr @_main
9474
jsr @_exit
9575

96-
.section .stack
97-
_stack: .long 1
76+
.section .stack, "aw", @nobits
77+
#ifdef __NORMAL_MODE__
78+
_stack: .space 2
79+
#else
80+
_stack: .space 4
81+
#endif
9882

9983
#endif

0 commit comments

Comments
 (0)