diff options
Diffstat (limited to 'libgloss/mcore/crt0.S')
-rw-r--r-- | libgloss/mcore/crt0.S | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libgloss/mcore/crt0.S b/libgloss/mcore/crt0.S new file mode 100644 index 000000000..cea437019 --- /dev/null +++ b/libgloss/mcore/crt0.S @@ -0,0 +1,49 @@ +// MCore StartUp Code. + + .import main + .import exit + + .text + .export _start +_start: + .export _mainCRTStartup +_mainCRTStartup: + // Initialise the stack pointer + lrw r1, _stack + mov r0, r1 + + // Zero the .bss data space + lrw r1, __bss_start__ + lrw r2, __bss_end__ + movi r3, 0 +.L0: + st r3, (r1, 0) + addi r1, 4 + cmphs r1, r2 + bf .L0 +#ifdef __ELF__ + // Call the global/static constructors + jbsr _init + + // Setup destructors to be called from exit, + // just in case main never returns... + lrw r2, _fini + jbsr atexit +#endif + + // Initialise the parameters to main() + movi r2, 0 // argc + movi r3, 0 // argv + movi r4, 0 // envp + + // Call main + jbsr main + + // Call exit + movi r2, 0 + jbsr exit + + // We should never reach here. + bkpt + + |