4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-23 23:47:22 +08:00
Jeff Law ec119e1084 Minor improvement to H8 startup code
Basically the startup code needs to clear memory from _edata to _end. In the
past it's been done with a fairly naive copy loop.  This changes the code to
just call memset and let memset figure out a sensible way to handle the
operation given the size and alignment requirements.

I don't have performance data on this.  I cobbled it together some time ago in
response to seeing some of the GCC tests with larger .bss sections taking an
insane amount of time to just get from _start to main.  With the fixes to the
H8 decoder in the simulator it may not matter nearly as much anymore.

This has been in my tester for months.  Naturally it does not cause any
regressions in the H8 port.
2023-12-31 09:08:21 -07:00

100 lines
1.3 KiB
ArmAsm

; h8/300 and h8/300h start up file.
#include "setarch.h"
#ifdef __H8300__
.section .text
.global _start
_start:
mov.w #_stack,sp
mov.w #_edata,r0
mov.w #_end,r2
sub.w r1,r1
sub.w r0,r2
jsr @_memset
#ifdef __ELF__
mov.l #__fini,r0
jsr @_atexit
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @__init
#else
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @___main
#endif
jsr @_main
jsr @_exit
.section .stack
_stack: .word 1
#endif
#ifdef __H8300H__
.section .text
.global _start
_start:
mov.l #_stack,sp
mov.l #_edata,er0
mov.l #_end,er2
sub.w r1,r1
sub.l er0,er2
jsr @_memset
#ifdef __ELF__
mov.l #__fini,er0
jsr @_atexit
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @__init
#else
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @___main
#endif
jsr @_main
jsr @_exit
.section .stack
_stack: .long 1
#endif
#if defined (__H8300S__) || defined (__H8300SX__)
.section .text
.global _start
_start:
mov.l #_stack,sp
mov.l #_edata,er0
mov.l #_end,er2
sub.w r1,r1
sub.l er0,er2
jsr @_memset
#ifdef __ELF__
mov.l #__fini,er0
jsr @_atexit
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @__init
#else
#ifdef __SIMULATOR__
jsr @0xcc
#endif
jsr @___main
#endif
jsr @_main
jsr @_exit
.section .stack
_stack: .long 1
#endif