cprt0.as 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
  5. # and Peter Vreman
  6. # members of the Free Pascal development team.
  7. #
  8. # See the file COPYING.FPC, included in this distribution,
  9. # for details about the copyright.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. #**********************************************************************}
  16. #
  17. # FreeBSD ELF startup code for Free Pascal for dynamical linking to libc.
  18. #
  19. .file "cprt0.as"
  20. .version "01.01"
  21. gcc2_compiled.:
  22. .globl __progname
  23. .section .rodata
  24. .LC0:
  25. .ascii "\0"
  26. .data
  27. .p2align 2
  28. .type __progname,@object
  29. .size __progname,4
  30. __progname:
  31. .long .LC0
  32. .align 4
  33. ___fpucw:
  34. .long 0x1332
  35. .globl ___fpc_brk_addr /* heap management */
  36. .type ___fpc_brk_addr,@object
  37. .size ___fpc_brk_addr,4
  38. ___fpc_brk_addr:
  39. .long 0
  40. .text
  41. .p2align 2
  42. .globl _start
  43. .type _start,@function
  44. _start:
  45. pushl %ebp
  46. movl %esp,%ebp
  47. pushl %edi
  48. pushl %esi
  49. pushl %ebx
  50. #APP
  51. movl %edx,%edx
  52. #NO_APP
  53. leal 8(%ebp),%edi
  54. movl %edi,operatingsystem_parameter_argv
  55. mov -4(%edi),%eax
  56. movl %eax,operatingsystem_parameter_argc
  57. movl 4(%ebp),%ebx
  58. leal 12(%ebp,%ebx,4),%esi
  59. movl %esi,operatingsystem_parameter_envp
  60. movl %esi,environ
  61. testl %ebx,%ebx
  62. jle .L2
  63. movl 8(%ebp),%eax
  64. testl %eax,%eax
  65. je .L2
  66. movl %eax,__progname
  67. cmpb $0,(%eax)
  68. je .L2
  69. .p2align 2,0x90
  70. .L6:
  71. cmpb $47,(%eax)
  72. jne .L5
  73. leal 1(%eax),%ecx
  74. movl %ecx,__progname
  75. .L5:
  76. incl %eax
  77. cmpb $0,(%eax)
  78. jne .L6
  79. .L2:
  80. movl $_DYNAMIC,%eax
  81. testl %eax,%eax
  82. je .L9
  83. pushl %edx
  84. call atexit
  85. addl $4,%esp
  86. .L9:
  87. pushl $_fini
  88. call atexit
  89. call _init
  90. # pushl %esi
  91. # pushl %edi
  92. # pushl %ebx
  93. # call main
  94. # pushl %eax
  95. # call exit
  96. finit /* initialize fpu */
  97. fwait
  98. fldcw ___fpucw
  99. xorl %ebp,%ebp
  100. call main
  101. pushl %eax
  102. jmp _haltproc
  103. .p2align 2,0x90
  104. .globl _haltproc
  105. .type _haltproc,@function
  106. _haltproc:
  107. mov $1,%eax
  108. movzwl operatingsystem_result,%ebx
  109. pushl %ebx
  110. call .Lactualsyscall
  111. addl $4,%esp
  112. jmp _haltproc
  113. .Lactualsyscall:
  114. int $0x80
  115. jb .LErrorcode
  116. xor %ebx,%ebx
  117. ret
  118. .LErrorcode:
  119. mov %eax,%ebx
  120. mov $-1,%eax
  121. ret
  122. .p2align 2,0x90
  123. .Lfe1:
  124. .size _start,.Lfe1-_start
  125. .comm environ,4,4
  126. .weak _DYNAMIC
  127. .ident "GCC: (GNU) 2.7.2.1"
  128. .bss
  129. .comm operatingsystem_parameter_envp,4
  130. .comm operatingsystem_parameter_argc,4
  131. .comm operatingsystem_parameter_argv,4