gprt0.as 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 with profiling support for Free Pascal
  17. # Note: Needs linking with -lgmon and -lc
  18. #
  19. .file "gprt1.as"
  20. .text
  21. .globl _start
  22. .type _start,@function
  23. _start:
  24. /* First locate the start of the environment variables */
  25. popl %ecx
  26. movl %esp,%ebx /* Points to the arguments */
  27. movl %ecx,%eax
  28. incl %eax
  29. shll $2,%eax
  30. addl %esp,%eax
  31. andl $0xfffffff8,%esp /* Align stack */
  32. movl %eax,U_SYSTEM_ENVP /* Move the environment pointer */
  33. movl %ecx,U_SYSTEM_ARGC /* Move the argument counter */
  34. movl %ebx,U_SYSTEM_ARGV /* Move the argument pointer */
  35. finit /* initialize fpu */
  36. fwait
  37. fldcw ___fpucw
  38. pushl $_etext /* Initialize gmon */
  39. pushl $_start
  40. call monstartup
  41. addl $8,%esp
  42. pushl $_mcleanup
  43. call atexit
  44. addl $4,%esp
  45. xorl %ebp,%ebp
  46. call PASCALMAIN
  47. .globl _haltproc
  48. .type _haltproc,@function
  49. _haltproc:
  50. xorl %ebx,%ebx /* load and save exitcode */
  51. movw U_SYSTEM_EXITCODE,%bx
  52. pushl %ebx
  53. call exit /* call libc exit, this will */
  54. /* write the gmon.out */
  55. movl $1,%eax /* exit call */
  56. popl %ebx
  57. int $0x80
  58. jmp _haltproc
  59. .data
  60. .align 4
  61. ___fpucw:
  62. .long 0x1332
  63. .globl ___fpc_brk_addr /* heap management */
  64. .type ___fpc_brk_addr,@object
  65. .size ___fpc_brk_addr,4
  66. ___fpc_brk_addr:
  67. .long 0
  68. #
  69. # $Log$
  70. # Revision 1.2 2000-10-15 09:09:23 peter
  71. # * startup code also needed syslinux->system updates
  72. #
  73. # Revision 1.1 2000/07/13 06:30:55 michael
  74. # + Initial import
  75. #