2
0

cprt0.as 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /* reload the addresses for C startup code */
  28. ld [%sp+22*4], %o1
  29. add %sp, 23*4, %o2
  30. /* Load the addresses of the user entry points. */
  31. sethi %hi(PASCALMAIN), %o0
  32. sethi %hi(_init), %o3
  33. sethi %hi(_fini), %o4
  34. or %o0, %lo(PASCALMAIN), %o0
  35. or %o3, %lo(_init), %o3
  36. or %o4, %lo(_fini), %o4
  37. /* When starting a binary via the dynamic linker, %g1 contains the
  38. address of the shared library termination function, which will be
  39. registered with atexit(). If we are statically linked, this will
  40. be NULL. */
  41. mov %g1, %o5
  42. /* Let libc do the rest of the initialization, and call main. */
  43. call __libc_start_main
  44. nop
  45. /* Die very horribly if exit returns. */
  46. unimp
  47. .size _start, .-_start
  48. .globl _haltproc
  49. .type _haltproc,@function
  50. _haltproc:
  51. mov 1, %g1 /* "exit" system call */
  52. sethi %hi(operatingsystem_result),%o0
  53. or %o0,%lo(operatingsystem_result),%o0
  54. ldsh [%o0], %o0 /* give exit status to parent process*/
  55. ta 0x10 /* dot the system call */
  56. nop /* delay slot */
  57. /* Die very horribly if exit returns. */
  58. unimp
  59. .data
  60. .comm ___fpc_brk_addr,4 /* heap management */
  61. .comm operatingsystem_parameter_envp,4
  62. .comm operatingsystem_parameter_argc,4
  63. .comm operatingsystem_parameter_argv,4