prt0.as 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 1999-2004 by Michael Van Canneyt, Peter Vreman,
  4. # & Daniel Mantione, 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. # The code in this file is the default startup code, it is used unless
  18. # libc is linked in, profiling is enabled or you are compiling a shared
  19. # library.
  20. #
  21. /*
  22. %a1 Contains a function pointer to be registered with `atexit'.
  23. This is how the dynamic linker arranges to have DT_FINI
  24. functions called for shared libraries that have been loaded
  25. before this code runs.
  26. %sp The stack contains the arguments and environment:
  27. 0(%sp) argc
  28. 4(%sp) argv[0]
  29. ...
  30. (4*argc)(%sp) NULL
  31. (4*(argc+1))(%sp) envp[0]
  32. ...
  33. NULL
  34. */
  35. .text
  36. .globl _start
  37. .type _start,@function
  38. _start:
  39. /* Clear the frame pointer. The ABI suggests this be done, to mark
  40. the outermost frame obviously. */
  41. sub.l %fp, %fp
  42. /* Extract the arguments as encoded on the stack and set up the
  43. arguments for `main': argc, argv. envp will be determined
  44. later in __libc_start_main. */
  45. move.l 8(%sp), %d0
  46. move.l %d0, operatingsystem_parameter_envp
  47. move.l 4(%sp), %d0
  48. move.l %d0, operatingsystem_parameter_argv
  49. move.l (%sp), %d0
  50. move.l %d0, operatingsystem_parameter_argc
  51. jbsr PASCALMAIN
  52. illegal /* Crash if somehow `exit' does return. */
  53. .file "prt0.as"
  54. .text
  55. .globl __entry
  56. __entry:
  57. jsr PASCALMAIN
  58. .globl _haltproc
  59. .type _haltproc,@function
  60. _haltproc:
  61. move.l #1,%d0
  62. move.l operatingsystem_result,%d1
  63. trap #0
  64. bras _haltproc
  65. .bss
  66. .type operatingsystem_parameters,@object
  67. .size operatingsystem_parameters,12
  68. operatingsystem_parameters:
  69. .skip 3*4
  70. .global operatingsystem_parameter_envp
  71. .global operatingsystem_parameter_argc
  72. .global operatingsystem_parameter_argv
  73. .set operatingsystem_parameter_envp,operatingsystem_parameters+0
  74. .set operatingsystem_parameter_argc,operatingsystem_parameters+4
  75. .set operatingsystem_parameter_argv,operatingsystem_parameters+8