prt0.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # $Id$
  2. /* Startup code for elf32-sparc
  3. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by Richard Henderson <[email protected]>, 1997.
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; if not, write to the Free
  16. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17. 02111-1307 USA. */
  18. .section ".text"
  19. .align 4
  20. .global _start
  21. .type _start,#function
  22. _start:
  23. /* Terminate the stack frame, and reserve space for functions to
  24. drop their arguments. */
  25. mov %g0, %fp
  26. sub %sp, 6*4, %sp
  27. /* Extract the arguments and environment as encoded on the stack. The
  28. argument info starts after one register window (16 words) past the SP. */
  29. ld [%sp+22*4], %o2
  30. sethi %hi(operatingsystem_parameter_argc),%o1
  31. or %o1,%lo(operatingsystem_parameter_argc),%o1
  32. st %o2, [%o1]
  33. add %sp, 23*4, %o0
  34. sethi %hi(operatingsystem_parameter_argv),%o1
  35. or %o1,%lo(operatingsystem_parameter_argv),%o1
  36. st %o0, [%o1]
  37. /* envp=(argc+1)*4+argv */
  38. inc %o2
  39. sll %o2, 2, %o2
  40. add %o2, %o0, %o2
  41. sethi %hi(operatingsystem_parameter_envp),%o1
  42. or %o1,%lo(operatingsystem_parameter_envp),%o1
  43. st %o2, [%o1]
  44. /* Call the user program entry point. */
  45. call PASCALMAIN
  46. nop
  47. .globl _haltproc
  48. .type _haltproc,@function
  49. _haltproc:
  50. mov 1, %g1 /* "exit" system call */
  51. sethi %hi(U_SYSTEM_EXITCODE),%o0
  52. or %o0,%lo(U_SYSTEM_EXITCODE),%o0
  53. ldsh [%o0], %o0 /* give exit status to parent process*/
  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. .bss
  60. .comm operatingsystem_parameter_envp,4
  61. .comm operatingsystem_parameter_argc,4
  62. .comm operatingsystem_parameter_argv,4
  63. #
  64. # $Log$
  65. # Revision 1.8 2004-07-03 21:50:31 daniel
  66. # * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
  67. # longer necessary
  68. #
  69. # Revision 1.7 2004/05/27 23:15:02 peter
  70. # * startup argc,argv,envp fix
  71. # * stat fixed
  72. #
  73. # Revision 1.6 2004/05/17 20:56:56 peter
  74. # * use ldsh to load exitcode
  75. #
  76. # Revision 1.5 2004/03/16 10:19:11 mazen
  77. # + _haltproc definition for linux/sparc
  78. #
  79. # Revision 1.4 2003/06/02 22:03:37 mazen
  80. # *making init and fini symbols compatible FPC code by
  81. # changing _init ==> fpc_initialize
  82. # and _fini ==> fpc_finalize
  83. #
  84. # Revision 1.3 2002/11/18 19:03:46 mazen
  85. # * start code of gcc adapted for FPC
  86. #