cprt0.as 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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(PASCALMAIN), %o0
  35. sethi %hi(_init), %o3
  36. sethi %hi(_fini), %o4
  37. or %o0, %lo(PASCALMAIN), %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. .globl _haltproc
  52. .type _haltproc,@function
  53. _haltproc:
  54. mov 1, %g1 /* "exit" system call */
  55. sethi %hi(operatingsystem_result),%o0
  56. or %o0,%lo(operatingsystem_result),%o0
  57. ldsh [%o0], %o0 /* give exit status to parent process*/
  58. ta 0x10 /* dot the system call */
  59. nop /* delay slot */
  60. /* Die very horribly if exit returns. */
  61. unimp
  62. .data
  63. .comm ___fpc_brk_addr,4 /* heap management */
  64. .comm operatingsystem_parameter_envp,4
  65. .comm operatingsystem_parameter_argc,4
  66. .comm operatingsystem_parameter_argv,4
  67. /*
  68. $Log$
  69. Revision 1.5 2004-09-25 18:43:45 florian
  70. * fixed symbol names
  71. Revision 1.4 2004/09/25 12:25:32 florian
  72. * first implementation
  73. Revision 1.3 2003/05/23 21:09:14 florian
  74. + dummy implementation readded to satisfy makefile
  75. */