cprt0.as 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. .section ".text"
  2. .align 4
  3. .global _start
  4. .type _start,#function
  5. _start:
  6. /* Terminate the stack frame, and reserve space for functions to
  7. drop their arguments. */
  8. mov %g0, %fp
  9. sub %sp, 6*4, %sp
  10. /* Extract the arguments and environment as encoded on the stack. The
  11. argument info starts after one register window (16 words) past the SP. */
  12. ld [%sp+22*4], %o2
  13. sethi %hi(operatingsystem_parameter_argc),%o1
  14. or %o1,%lo(operatingsystem_parameter_argc),%o1
  15. st %o2, [%o1]
  16. add %sp, 23*4, %o0
  17. sethi %hi(operatingsystem_parameter_argv),%o1
  18. or %o1,%lo(operatingsystem_parameter_argv),%o1
  19. st %o0, [%o1]
  20. /* envp=(argc+1)*4+argv */
  21. inc %o2
  22. sll %o2, 2, %o2
  23. add %o2, %o0, %o2
  24. sethi %hi(operatingsystem_parameter_envp),%o1
  25. or %o1,%lo(operatingsystem_parameter_envp),%o1
  26. st %o2, [%o1]
  27. /* Save initial stackpointer */
  28. sethi %hi(__stkptr),%o1
  29. or %o1,%lo(__stkptr),%o1
  30. st %sp, [%o1]
  31. /* reload the addresses for C startup code */
  32. ld [%sp+22*4], %o1
  33. add %sp, 23*4, %o2
  34. /* Load the addresses of the user entry points. */
  35. sethi %hi(PASCALMAIN), %o0
  36. sethi %hi(_init), %o3
  37. sethi %hi(_fini), %o4
  38. or %o0, %lo(PASCALMAIN), %o0
  39. or %o3, %lo(_init), %o3
  40. or %o4, %lo(_fini), %o4
  41. /* When starting a binary via the dynamic linker, %g1 contains the
  42. address of the shared library termination function, which will be
  43. registered with atexit(). If we are statically linked, this will
  44. be NULL. */
  45. mov %g1, %o5
  46. /* Let libc do the rest of the initialization, and call main. */
  47. call __libc_start_main
  48. nop
  49. /* Die very horribly if exit returns. */
  50. unimp
  51. .size _start, .-_start
  52. .globl _haltproc
  53. .type _haltproc,@function
  54. _haltproc:
  55. mov 188, %g1 /* "exit" system call */
  56. ta 0x10 /* dot the system call */
  57. nop /* delay slot */
  58. /* Die very horribly if exit returns. */
  59. unimp
  60. .data
  61. .comm __stkptr,4
  62. .comm operatingsystem_parameter_envp,4
  63. .comm operatingsystem_parameter_argc,4
  64. .comm operatingsystem_parameter_argv,4