cprt0.as 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. # Used by System_exit procedure
  52. .globl _haltproc
  53. .type _haltproc,@function
  54. _haltproc:
  55. # Call C exit function
  56. move.l operatingsystem_result,%d1
  57. move.l %d1,-(%sp)
  58. jsr exit
  59. moveq.l #1,%d0
  60. move.l (%sp)+,%d1
  61. trap #0
  62. bra _haltproc
  63. .size _haltproc,.-_haltproc
  64. .bss
  65. .type __stkptr,@object
  66. .size __stkptr,4
  67. .global __stkptr
  68. __stkptr:
  69. .skip 4
  70. .type operatingsystem_parameters,@object
  71. .size operatingsystem_parameters,12
  72. operatingsystem_parameters:
  73. .skip 3*4
  74. .global operatingsystem_parameter_envp
  75. .global operatingsystem_parameter_argc
  76. .global operatingsystem_parameter_argv
  77. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  78. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  79. .set operatingsystem_parameter_argv,operatingsystem_parameters+8