gprt0.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. $Id$
  3. */
  4. .section ".text"
  5. .align 4
  6. .global _start
  7. .type _start,#function
  8. _start:
  9. /* Terminate the stack frame, and reserve space for functions to
  10. drop their arguments. */
  11. mov %g0, %fp
  12. sub %sp, 6*4, %sp
  13. /* Extract the arguments and environment as encoded on the stack. The
  14. argument info starts after one register window (16 words) past the SP. */
  15. ld [%sp+22*4], %o2
  16. sethi %hi(operatingsystem_parameter_argc),%o1
  17. or %o1,%lo(operatingsystem_parameter_argc),%o1
  18. st %o2, [%o1]
  19. add %sp, 23*4, %o0
  20. sethi %hi(operatingsystem_parameter_argv),%o1
  21. or %o1,%lo(operatingsystem_parameter_argv),%o1
  22. st %o0, [%o1]
  23. /* envp=(argc+1)*4+argv */
  24. inc %o2
  25. sll %o2, 2, %o2
  26. add %o2, %o0, %o2
  27. sethi %hi(operatingsystem_parameter_envp),%o1
  28. or %o1,%lo(operatingsystem_parameter_envp),%o1
  29. st %o2, [%o1]
  30. /* reload the addresses for C startup code */
  31. ld [%sp+22*4], %o1
  32. add %sp, 23*4, %o2
  33. /* Load the addresses of the user entry points. */
  34. sethi %hi(main_stub), %o0
  35. sethi %hi(_init), %o3
  36. sethi %hi(_fini), %o4
  37. or %o0, %lo(main_stub), %o0
  38. or %o3, %lo(_init), %o3
  39. or %o4, %lo(_fini), %o4
  40. /* When starting a binary via the dynamic linker, %g1 contains the
  41. address of the shared library termination function, which will be
  42. registered with atexit(). If we are statically linked, this will
  43. be NULL. */
  44. mov %g1, %o5
  45. /* Let libc do the rest of the initialization, and call main. */
  46. call __libc_start_main
  47. nop
  48. /* Die very horribly if exit returns. */
  49. unimp
  50. .size _start, .-_start
  51. main_stub:
  52. /* Initialize gmon */
  53. sethi %hi(_start), %o0
  54. sethi %hi(_etext), %o1
  55. or %o0, %lo(_start), %o0
  56. or %o1, %lo(_etext), %o1
  57. call monstartup
  58. nop
  59. sethi %hi(_mcleanup), %o0
  60. or %o0, %lo(_mcleanup), %o0
  61. call atexit
  62. nop
  63. /* start the program */
  64. call PASCALMAIN
  65. nop
  66. ba _haltproc
  67. nop
  68. .globl _haltproc
  69. .type _haltproc,@function
  70. _haltproc:
  71. mov 1, %g1 /* "exit" system call */
  72. sethi %hi(operatingsystem_result),%o0
  73. or %o0,%lo(operatingsystem_result),%o0
  74. ldsh [%o0], %o0 /* give exit status to parent process*/
  75. ta 0x10 /* dot the system call */
  76. nop /* delay slot */
  77. /* Die very horribly if exit returns. */
  78. unimp
  79. .data
  80. .comm ___fpc_brk_addr,4 /* heap management */
  81. .comm operatingsystem_parameter_envp,4
  82. .comm operatingsystem_parameter_argc,4
  83. .comm operatingsystem_parameter_argv,4
  84. /*
  85. $Log$
  86. Revision 1.4 2004-11-05 21:36:36 florian
  87. * initial implementation
  88. Revision 1.3 2003/05/23 21:09:14 florian
  89. + dummy implementation readded to satisfy makefile
  90. */