gprt1.as 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1993,97 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_SYSLINUX_ENVP /* Move the environment pointer */
  33. movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */
  34. movl %ebx,U_SYSLINUX_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. call PASCALMAIN
  46. .globl _haltproc
  47. .type _haltproc,@function
  48. _haltproc:
  49. xorl %ebx,%ebx /* load and save exitcode */
  50. movw U_SYSLINUX_EXITCODE,%bx
  51. pushl %ebx
  52. call exit /* call libc exit, this will */
  53. /* write the gmon.out */
  54. movl $1,%eax /* exit call */
  55. popl %ebx
  56. int $0x80
  57. jmp _haltproc
  58. .data
  59. .align 4
  60. ___fpucw:
  61. .long 0x1332
  62. .globl ___fpc_brk_addr /* heap management */
  63. .type ___fpc_brk_addr,@object
  64. .size ___fpc_brk_addr,4
  65. ___fpc_brk_addr:
  66. .long 0
  67. .globl __curbrk /* necessary for libc */
  68. .type __curbrk,@object
  69. .size __curbrk,4
  70. __curbrk:
  71. .long 0
  72. #
  73. # $Log$
  74. # Revision 1.4 1998-10-14 21:28:48 peter
  75. # * initialize fpu so sigfpe is finally generated for fpu errors
  76. #
  77. # Revision 1.3 1998/08/08 14:42:10 peter
  78. # * added missing ___fpc_sbrk and logs
  79. #
  80. #