prt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2004 by Michael Van Canneyt, Peter Vreman,
  5. # & Daniel Mantione, members of the Free Pascal development team.
  6. #
  7. # See the file COPYING.FPC, included in this distribution,
  8. # for details about the copyright.
  9. #
  10. # This program 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.
  13. #
  14. #**********************************************************************}
  15. #
  16. # Linux ELF startup code for Free Pascal
  17. #
  18. # The code in this file is the default startup code, it is used unless
  19. # libc is linked in, profiling is enabled or you are compiling a shared
  20. # library.
  21. #
  22. #
  23. # Stack layout at program start:
  24. #
  25. # nil
  26. # envn
  27. # ....
  28. # .... ENVIRONMENT VARIABLES
  29. # env1
  30. # env0
  31. # nil
  32. # argn
  33. # ....
  34. # .... COMMAND LINE OPTIONS
  35. # arg1
  36. # arg0
  37. # argc <--- esp
  38. #
  39. .file "prt0.as"
  40. .text
  41. .globl _start
  42. .type _start,@function
  43. _start:
  44. /* First locate the start of the environment variables */
  45. popl %ecx /* Get argc in ecx */
  46. movl %esp,%ebx /* Esp now points to the arguments */
  47. leal 4(%esp,%ecx,4),%eax /* The start of the environment is: esp+4*eax+4 */
  48. andl $0xfffffff8,%esp /* Align stack */
  49. leal operatingsystem_parameters,%edi
  50. stosl /* Move the environment pointer */
  51. xchg %ecx,%eax
  52. stosl /* Move the argument counter */
  53. xchg %ebx,%eax
  54. stosl /* Move the argument pointer */
  55. fninit /* initialize fpu */
  56. fwait
  57. fldcw ___fpucw
  58. xorl %ebp,%ebp
  59. call PASCALMAIN
  60. .globl _haltproc
  61. .type _haltproc,@function
  62. _haltproc:
  63. _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is exported
  64. xorl %eax,%eax
  65. incl %eax /* eax=1, exit call */
  66. movzwl operatingsystem_result,%ebx
  67. int $0x80
  68. jmp _haltproc2
  69. .data
  70. ___fpucw:
  71. .long 0x1332
  72. .bss
  73. .type ___fpc_brk_addr,@object
  74. .comm ___fpc_brk_addr,4 /* heap management */
  75. operatingsystem_parameters:
  76. .skip 3*4
  77. .global operatingsystem_parameter_envp
  78. .global operatingsystem_parameter_argc
  79. .global operatingsystem_parameter_argv
  80. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  81. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  82. .set operatingsystem_parameter_argv,operatingsystem_parameters+8
  83. #
  84. # $Log$
  85. # Revision 1.5 2004-07-03 23:04:34 daniel
  86. # * Updated comments
  87. #
  88. # Revision 1.4 2004/07/03 21:50:31 daniel
  89. # * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
  90. # longer necessary
  91. #
  92. # Revision 1.3 2002/09/07 16:01:20 peter
  93. # * old logs removed and tabs fixed
  94. #