cprt0.as 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
  5. # 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. .file "prt1.as"
  19. .text
  20. .globl _start
  21. .type _start,@function
  22. _start:
  23. /* First locate the start of the environment variables */
  24. popl %ecx
  25. movl %esp,%ebx /* Points to the arguments */
  26. movl %ecx,%eax
  27. incl %eax
  28. shll $2,%eax
  29. addl %esp,%eax
  30. andl $0xfffffff8,%esp /* Align stack */
  31. movl %eax,U_SYSTEM_ENVP /* Move the environment pointer */
  32. movl %ecx,U_SYSTEM_ARGC /* Move the argument counter */
  33. movl %ebx,U_SYSTEM_ARGV /* Move the argument pointer */
  34. movl %eax,__environ /* libc environ */
  35. pushl %eax
  36. pushl %ebx
  37. pushl %ecx
  38. call __libc_init /* init libc */
  39. movzwl __fpu_control,%eax
  40. pushl %eax
  41. call __setfpucw
  42. addl $4,%esp
  43. pushl $_fini
  44. call atexit
  45. addl $4,%esp
  46. call _init
  47. popl %eax
  48. popl %eax
  49. xorl %ebp,%ebp
  50. call PASCALMAIN /* start the program */
  51. .globl _haltproc
  52. .type _haltproc,@function
  53. _haltproc:
  54. xorl %ebx,%ebx /* load and save exitcode */
  55. movw U_SYSTEM_EXITCODE,%bx
  56. pushl %ebx
  57. call exit /* call libc exit, this will */
  58. /* write the gmon.out */
  59. movl $1,%eax /* exit call */
  60. popl %ebx
  61. int $0x80
  62. jmp _haltproc
  63. .data
  64. .align 4
  65. .globl ___fpc_brk_addr /* heap management */
  66. .type ___fpc_brk_addr,@object
  67. .size ___fpc_brk_addr,4
  68. ___fpc_brk_addr:
  69. .long 0
  70. #
  71. # $Log$
  72. # Revision 1.3 2002-09-07 16:01:20 peter
  73. # * old logs removed and tabs fixed
  74. #