cprt21.as 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. |
  2. | $Id: cprt21.as,v 1.1.2.5 2002/02/28 22:44:44 pierre Exp $
  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. move.l (%sp)+,%d3
  25. move.l %d0,%d4
  26. move.l %sp,%d1 /* Points to the arguments */
  27. move.l %d3,%d0
  28. addq.l #1,%d0
  29. lsl.l #2,%d0
  30. add.l %sp,%d0
  31. move.l %sp,%d7
  32. and.l #0xfffffff8,%d7 /* Align stack */
  33. move.l %d7,%sp
  34. move.l %d0,U_SYSLINUX_ENVP /* Move the environment pointer */
  35. move.l %d3,U_SYSLINUX_ARGC /* Move the argument counter */
  36. move.l %d1,U_SYSLINUX_ARGV /* Move the argument pointer */
  37. move.l #0,%fp /* Zero frame pointer to end call stack */
  38. |
  39. | Start of args for __libc_start_main
  40. |
  41. |
  42. move.l %d4,-(%sp)
  43. move.l %sp,-(%sp)
  44. move.l %a1,-(%sp)
  45. pea.l _fini_dummy
  46. pea.l _init_dummy
  47. move.l %d1,-(%sp)
  48. move.l %d3,-(%sp)
  49. pea.l main
  50. jsr __libc_start_main
  51. trap #0
  52. /* fake main routine which will be run from libc */
  53. main:
  54. /* save return address */
  55. move.l (%sp)+,%d0
  56. move.l %d0,___fpc_ret
  57. move.l %d1,___fpc_ret_d1
  58. move.l %fp,___fpc_ret_fp
  59. move.l %d0,-(%sp)
  60. /* start the program */
  61. move.l #0,%fp
  62. jsr PASCALMAIN
  63. .globl _haltproc
  64. .type _haltproc,@function
  65. _haltproc:
  66. eor.l %d0,%d0 /* load and save exitcode */
  67. move.w U_SYSLINUX_EXITCODE,%d0
  68. move.l ___fpc_ret,%d3 /* return to libc */
  69. move.l ___fpc_ret_fp,%fp
  70. move.l ___fpc_ret_d1,%d1
  71. move.l %d3,-(%sp)
  72. _init_dummy:
  73. _fini_dummy:
  74. rts
  75. .data
  76. .align 4
  77. .globl ___fpc_brk_addr /* heap management */
  78. .type ___fpc_brk_addr,@object
  79. .size ___fpc_brk_addr,4
  80. ___fpc_brk_addr:
  81. .long 0
  82. ___fpc_ret: /* return address to libc */
  83. .long 0
  84. ___fpc_ret_d1:
  85. .long 0
  86. ___fpc_ret_fp:
  87. .long 0
  88. |
  89. | $Log: cprt21.as,v $
  90. | Revision 1.1.2.5 2002/02/28 22:44:44 pierre
  91. | + add some comments
  92. |
  93. | Revision 1.1.2.4 2001/08/02 21:23:59 pierre
  94. | * fix the args to __libc_start_main
  95. |
  96. | Revision 1.1.2.3 2001/07/30 20:05:07 pierre
  97. | * fix a assembler syntax eror in last commit
  98. |
  99. | Revision 1.1.2.2 2001/07/30 16:18:53 pierre
  100. | * converted from i386 code
  101. |
  102. | Revision 1.1.2.2 2001/06/04 18:04:32 peter
  103. | * use own dummies for _init and _fini
  104. |
  105. | Revision 1.1.2.1 2001/02/14 22:18:45 pierre
  106. | * fix Sebastian's problem with HeapTrace
  107. |
  108. | Revision 1.1 2000/07/13 06:30:55 michael
  109. | + Initial import
  110. |
  111. | Revision 1.3 2000/01/07 16:41:42 daniel
  112. | * copyright 2000
  113. |
  114. | Revision 1.2 2000/01/07 16:32:28 daniel
  115. | * copyright 2000 added
  116. |
  117. | Revision 1.1 1999/05/03 21:29:36 peter
  118. | + glibc 2.1 support
  119. |
  120. | Revision 1.3 1998/11/04 10:16:25 peter
  121. | + xorl fp,fp to indicate end of backtrace
  122. |
  123. | Revision 1.2 1998/10/14 21:28:46 peter
  124. | * initialize fpu so sigfpe is finally generated for fpu errors
  125. |
  126. | Revision 1.1 1998/08/12 19:16:09 peter
  127. | + loader including libc init and exit
  128. |
  129. |