prt0.as 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Startup code for elf32-sparc
  2. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Richard Henderson <[email protected]>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. .section ".text"
  18. .align 4
  19. .global _start
  20. .type _start,#function
  21. _start:
  22. /* Terminate the stack frame, and reserve space for functions to
  23. drop their arguments. */
  24. mov %g0, %fp
  25. sub %sp, 6*4, %sp
  26. /* Extract the arguments and environment as encoded on the stack. The
  27. argument info starts after one register window (16 words) past the SP. */
  28. ld [%sp+22*4], %o2
  29. sethi %hi(operatingsystem_parameter_argc),%o1
  30. or %o1,%lo(operatingsystem_parameter_argc),%o1
  31. st %o2, [%o1]
  32. add %sp, 23*4, %o0
  33. sethi %hi(operatingsystem_parameter_argv),%o1
  34. or %o1,%lo(operatingsystem_parameter_argv),%o1
  35. st %o0, [%o1]
  36. /* envp=(argc+1)*4+argv */
  37. inc %o2
  38. sll %o2, 2, %o2
  39. add %o2, %o0, %o2
  40. sethi %hi(operatingsystem_parameter_envp),%o1
  41. or %o1,%lo(operatingsystem_parameter_envp),%o1
  42. st %o2, [%o1]
  43. /* Save initial stackpointer */
  44. sethi %hi(__stkptr),%o1
  45. or %o1,%lo(__stkptr),%o1
  46. st %sp, [%o1]
  47. /* Call the user program entry point. */
  48. call PASCALMAIN
  49. nop
  50. .globl _haltproc
  51. .type _haltproc,@function
  52. _haltproc:
  53. mov 188, %g1 /* "exit_group" system call */
  54. ta 0x10 /* dot the system call */
  55. nop /* delay slot */
  56. /* Die very horribly if exit returns. */
  57. unimp
  58. .size _start, .-_start
  59. .comm __stkptr,4
  60. .comm operatingsystem_parameter_envp,4
  61. .comm operatingsystem_parameter_argc,4
  62. .comm operatingsystem_parameter_argv,4