prt0.as 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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(operatingsystem_result),%o0
  52. or %o0,%lo(operatingsystem_result),%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. .comm operatingsystem_parameter_envp,4
  60. .comm operatingsystem_parameter_argc,4
  61. .comm operatingsystem_parameter_argv,4
  62. #
  63. # $Log$
  64. # Revision 1.9 2004-07-05 21:07:38 florian
  65. # * remade makefile (too old fpcmake)
  66. # * fixed sparc startup code
  67. #
  68. # Revision 1.8 2004/07/03 21:50:31 daniel
  69. # * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
  70. # longer necessary
  71. #
  72. # Revision 1.7 2004/05/27 23:15:02 peter
  73. # * startup argc,argv,envp fix
  74. # * stat fixed
  75. #
  76. # Revision 1.6 2004/05/17 20:56:56 peter
  77. # * use ldsh to load exitcode
  78. #
  79. # Revision 1.5 2004/03/16 10:19:11 mazen
  80. # + _haltproc definition for linux/sparc
  81. #
  82. # Revision 1.4 2003/06/02 22:03:37 mazen
  83. # *making init and fini symbols compatible FPC code by
  84. # changing _init ==> fpc_initialize
  85. # and _fini ==> fpc_finalize
  86. #
  87. # Revision 1.3 2002/11/18 19:03:46 mazen
  88. # * start code of gcc adapted for FPC
  89. #