Last change
on this file since 551 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.9 KB
|
Rev | Line | |
---|
[444] | 1 | # NEC V850 startup code |
---|
| 2 | |
---|
| 3 | .section .text |
---|
| 4 | .global _start |
---|
| 5 | |
---|
| 6 | _start: |
---|
| 7 | |
---|
| 8 | #if defined(__v850e__) || defined(__v850e2__) || defined(__v850e2v3__) || defined(__v850e3v5__) |
---|
| 9 | |
---|
| 10 | movea 255, r0, r20 |
---|
| 11 | mov 65535, r21 |
---|
| 12 | mov hilo(_stack), sp |
---|
| 13 | mov hilo(__ep), ep |
---|
| 14 | mov hilo(__gp), gp |
---|
| 15 | mov hilo(__ctbp), r6 |
---|
| 16 | ldsr r6, ctbp |
---|
| 17 | #if defined(__v850e2v3__) || defined(__v850e3v5__) |
---|
| 18 | // FPU enable |
---|
| 19 | stsr psw, r6 |
---|
| 20 | movhi 1, r0, r7 |
---|
| 21 | or r7, r6 |
---|
| 22 | ldsr r6, psw |
---|
| 23 | // Initialize the FPSR |
---|
| 24 | movhi 2, r0, r6 |
---|
| 25 | ldsr r6, fpsr |
---|
| 26 | #endif |
---|
| 27 | // FIXME: We currently assume that the data sections |
---|
| 28 | // are loaded in place - ie that they do not need to |
---|
| 29 | // moved from eg ROM into RAM. If that is not true |
---|
| 30 | // then extra code needs to be added here. |
---|
| 31 | |
---|
| 32 | // Initialise the .bss section. |
---|
| 33 | mov hilo(_edata), r6 |
---|
| 34 | mov hilo(_end), r7 |
---|
| 35 | .L0: |
---|
| 36 | st.w r0, 0[r6] |
---|
| 37 | addi 4, r6, r6 |
---|
| 38 | cmp r7, r6 |
---|
| 39 | bl .L0 |
---|
| 40 | .L1: |
---|
| 41 | jarl ___main, r31 |
---|
| 42 | addi -16, sp, sp |
---|
| 43 | mov 0, r6 |
---|
| 44 | mov 0, r7 |
---|
| 45 | mov 0, r8 |
---|
| 46 | jarl _main, r31 |
---|
| 47 | mov r10, r6 |
---|
| 48 | jarl _exit, r31 |
---|
| 49 | |
---|
| 50 | # else |
---|
| 51 | movea 255, r0, r20 |
---|
| 52 | mov r0, r21 |
---|
| 53 | ori 65535, r0, r21 |
---|
| 54 | movhi hi(_stack), r0, sp |
---|
| 55 | movea lo(_stack), sp, sp |
---|
| 56 | movhi hi(__ep), r0, ep |
---|
| 57 | movea lo(__ep), ep, ep |
---|
| 58 | movhi hi(__gp), r0, gp |
---|
| 59 | movea lo(__gp), gp, gp |
---|
| 60 | |
---|
| 61 | // FIXME: See note about not moving the data sections above. |
---|
| 62 | |
---|
| 63 | // Initialise the .bss section. |
---|
| 64 | movhi hi(_edata), r0, r6 |
---|
| 65 | movea lo(_edata), r6, r6 |
---|
| 66 | movhi hi(_end), r0, r7 |
---|
| 67 | movea lo(_end), r7, r7 |
---|
| 68 | .L0: |
---|
| 69 | st.b r0, 0[r6] |
---|
| 70 | addi 1, r6, r6 |
---|
| 71 | cmp r7, r6 |
---|
| 72 | bl .L0 |
---|
| 73 | .L1: |
---|
| 74 | jarl ___main, r31 |
---|
| 75 | addi -16, sp, sp |
---|
| 76 | mov 0, r6 |
---|
| 77 | mov 0, r7 |
---|
| 78 | mov 0, r8 |
---|
| 79 | jarl _main, r31 |
---|
| 80 | mov r10, r6 |
---|
| 81 | jarl _exit, r31 |
---|
| 82 | # endif |
---|
| 83 | |
---|
| 84 | .section .stack |
---|
| 85 | _stack: .long 1 |
---|
| 86 | |
---|
| 87 | .section .data |
---|
| 88 | .global ___dso_handle |
---|
| 89 | .weak ___dso_handle |
---|
| 90 | ___dso_handle: |
---|
| 91 | .long 0 |
---|
Note: See
TracBrowser
for help on using the repository browser.