cprt0.as 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 2001 by Free Pascal Core Team
  4. #
  5. # See the file COPYING.FPC, included in this distribution,
  6. # for details about the copyright.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. #
  12. #**********************************************************************}
  13. #
  14. # Linux m68k ELF startup code for linking with C lib for Free Pascal
  15. #
  16. .file "cprt0.as"
  17. .text
  18. .globl _start
  19. .type _start,@function
  20. _start:
  21. .globl __entry
  22. .type __entry,@function
  23. __entry:
  24. ######### This order of parameters is for ucLibc.
  25. # move.l 8(%sp),%d0
  26. # move.l %d0,operatingsystem_parameter_envp
  27. # move.l %d0,__environ
  28. # move.l 4(%sp),%d0
  29. # move.l %d0,operatingsystem_parameter_argv
  30. # move.l (%sp),%d0
  31. # move.l %d0,operatingsystem_parameter_argc
  32. #########
  33. sub.l %fp,%fp
  34. move.l (%sp)+,%d0
  35. move.l %d0,operatingsystem_parameter_argc
  36. move.l %sp,operatingsystem_parameter_argv
  37. lea.l 8(%sp,%d0.l*4),%a0
  38. move.l %a0,operatingsystem_parameter_envp
  39. move.l %sp,%a0 /* argv */
  40. move.l %sp,__stkptr
  41. pea (%sp) /* highest available stack address */
  42. pea (%a1) /* termination function provided by kernel */
  43. pea __libc_csu_fini
  44. pea __libc_csu_init
  45. pea (%a0) /* argv */
  46. move.l %d0,-(%sp) /* argc */
  47. pea PASCALMAIN
  48. jsr __libc_start_main
  49. illegal
  50. .size _start,.-_start
  51. .weak __libc_csu_init
  52. .type __libc_csu_init,@function
  53. __libc_csu_init:
  54. rts
  55. .size __libc_csu_init,.-__libc_csu_init
  56. .weak __libc_csu_fini
  57. .type __libc_csu_fini,@function
  58. __libc_csu_fini:
  59. rts
  60. .size __libc_csu_fini,.-__libc_csu_fini
  61. # Used by System_exit procedure
  62. .globl _haltproc
  63. .type _haltproc,@function
  64. _haltproc:
  65. # Call C exit function
  66. move.l operatingsystem_result,%d1
  67. move.l %d1,-(%sp)
  68. jsr exit
  69. moveq.l #1,%d0
  70. move.l (%sp)+,%d1
  71. trap #0
  72. bra _haltproc
  73. .size _haltproc,.-_haltproc
  74. .bss
  75. .type __stkptr,@object
  76. .size __stkptr,4
  77. .global __stkptr
  78. __stkptr:
  79. .skip 4
  80. .type operatingsystem_parameters,@object
  81. .size operatingsystem_parameters,12
  82. operatingsystem_parameters:
  83. .skip 3*4
  84. .global operatingsystem_parameter_envp
  85. .global operatingsystem_parameter_argc
  86. .global operatingsystem_parameter_argv
  87. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  88. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  89. .set operatingsystem_parameter_argv,operatingsystem_parameters+8