cprt0.as 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. pea (%sp) /* highest available stack address */
  41. pea (%a1) /* termination function provided by kernel */
  42. pea __libc_csu_fini
  43. pea __libc_csu_init
  44. pea (%a0) /* argv */
  45. move.l %d0,-(%sp) /* argc */
  46. pea PASCALMAIN
  47. jsr __libc_start_main
  48. illegal
  49. .size _start,.-_start
  50. # Used by System_exit procedure
  51. .globl _haltproc
  52. .type _haltproc,@function
  53. _haltproc:
  54. # Call C exit function
  55. move.l operatingsystem_result,%d1
  56. move.l %d1,-(%sp)
  57. jsr exit
  58. moveq.l #1,%d0
  59. move.l (%sp)+,%d1
  60. trap #0
  61. bra _haltproc
  62. .size _haltproc,.-_haltproc
  63. .bss
  64. .type __stkptr,@object
  65. .size __stkptr,4
  66. .global __stkptr
  67. __stkptr:
  68. .skip 4
  69. .type operatingsystem_parameters,@object
  70. .size operatingsystem_parameters,12
  71. operatingsystem_parameters:
  72. .skip 3*4
  73. .global operatingsystem_parameter_envp
  74. .global operatingsystem_parameter_argc
  75. .global operatingsystem_parameter_argv
  76. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  77. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  78. .set operatingsystem_parameter_argv,operatingsystem_parameters+8