cprt21.as 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. |
  2. | This file is part of the Free Pascal run time library.
  3. | Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
  4. | members of the Free Pascal development team.
  5. |
  6. | See the file COPYING.FPC, included in this distribution,
  7. | for details about the copyright.
  8. |
  9. | This program is distributed in the hope that it will be useful,
  10. | but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. |
  13. |**********************************************************************}
  14. |
  15. | Linux ELF startup code for Free Pascal
  16. |
  17. .file "prt1.as"
  18. .text
  19. .globl _start
  20. .type _start,@function
  21. _start:
  22. /* First locate the start of the environment variables */
  23. move.l (%sp)+,%d3
  24. move.l %d0,%d4
  25. move.l %sp,%d1 /* Points to the arguments */
  26. move.l %d3,%d0
  27. addq.l #1,%d0
  28. lsl.l #2,%d0
  29. add.l %sp,%d0
  30. move.l %sp,%d7
  31. and.l #0xfffffff8,%d7 /* Align stack */
  32. move.l %d7,%sp
  33. move.l %d0,U_SYSLINUX_ENVP /* Move the environment pointer */
  34. move.l %d3,U_SYSLINUX_ARGC /* Move the argument counter */
  35. move.l %d1,U_SYSLINUX_ARGV /* Move the argument pointer */
  36. move.l #0,%fp /* Zero frame pointer to end call stack */
  37. |
  38. | Start of args for __libc_start_main
  39. |
  40. |
  41. move.l %d4,-(%sp)
  42. move.l %sp,-(%sp)
  43. move.l %a1,-(%sp)
  44. pea.l _fini_dummy
  45. pea.l _init_dummy
  46. move.l %d1,-(%sp)
  47. move.l %d3,-(%sp)
  48. pea.l main
  49. jsr __libc_start_main
  50. trap #0
  51. /* fake main routine which will be run from libc */
  52. main:
  53. /* save return address */
  54. move.l (%sp)+,%d0
  55. move.l %d0,___fpc_ret
  56. move.l %d1,___fpc_ret_d1
  57. move.l %fp,___fpc_ret_fp
  58. move.l %d0,-(%sp)
  59. /* start the program */
  60. move.l #0,%fp
  61. jsr PASCALMAIN
  62. .globl _haltproc
  63. .type _haltproc,@function
  64. _haltproc:
  65. eor.l %d0,%d0 /* load and save exitcode */
  66. move.w U_SYSLINUX_EXITCODE,%d0
  67. move.l ___fpc_ret,%d3 /* return to libc */
  68. move.l ___fpc_ret_fp,%fp
  69. move.l ___fpc_ret_d1,%d1
  70. move.l %d3,-(%sp)
  71. _init_dummy:
  72. _fini_dummy:
  73. rts
  74. .data
  75. .align 4
  76. .globl ___fpc_brk_addr /* heap management */
  77. .type ___fpc_brk_addr,@object
  78. .size ___fpc_brk_addr,4
  79. ___fpc_brk_addr:
  80. .long 0
  81. ___fpc_ret: /* return address to libc */
  82. .long 0
  83. ___fpc_ret_d1:
  84. .long 0
  85. ___fpc_ret_fp:
  86. .long 0