Last change
on this file since 557 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
749 bytes
|
Rev | Line | |
---|
[444] | 1 | // MCore StartUp Code. |
---|
| 2 | |
---|
| 3 | .import main |
---|
| 4 | .import exit |
---|
| 5 | |
---|
| 6 | .text |
---|
| 7 | .export _start |
---|
| 8 | _start: |
---|
| 9 | .export _mainCRTStartup |
---|
| 10 | _mainCRTStartup: |
---|
| 11 | // Initialise the stack pointer |
---|
| 12 | lrw r1, _stack |
---|
| 13 | mov r0, r1 |
---|
| 14 | |
---|
| 15 | // Zero the .bss data space |
---|
| 16 | lrw r1, __bss_start__ |
---|
| 17 | lrw r2, __bss_end__ |
---|
| 18 | movi r3, 0 |
---|
| 19 | .L0: |
---|
| 20 | st r3, (r1, 0) |
---|
| 21 | addi r1, 4 |
---|
| 22 | cmphs r1, r2 |
---|
| 23 | bf .L0 |
---|
| 24 | #ifdef __ELF__ |
---|
| 25 | // Call the global/static constructors |
---|
| 26 | jbsr _init |
---|
| 27 | |
---|
| 28 | // Setup destructors to be called from exit, |
---|
| 29 | // just in case main never returns... |
---|
| 30 | lrw r2, _fini |
---|
| 31 | jbsr atexit |
---|
| 32 | #endif |
---|
| 33 | |
---|
| 34 | // Initialise the parameters to main() |
---|
| 35 | movi r2, 0 // argc |
---|
| 36 | movi r3, 0 // argv |
---|
| 37 | movi r4, 0 // envp |
---|
| 38 | |
---|
| 39 | // Call main |
---|
| 40 | jbsr main |
---|
| 41 | |
---|
| 42 | // Call exit |
---|
| 43 | movi r2, 0 |
---|
| 44 | jbsr exit |
---|
| 45 | |
---|
| 46 | // We should never reach here. |
---|
| 47 | bkpt |
---|
| 48 | |
---|
| 49 | |
---|
Note: See
TracBrowser
for help on using the repository browser.