prt0.as 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 2013 by Yury Sidorov and other
  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. # Program startup code for Free Pascal. Android-ARM target.
  16. #
  17. /* At this entry point, most registers' values are unspecified, except:
  18. sp The stack contains the arguments and environment:
  19. 0(sp) argc
  20. 4(sp) argv[0]
  21. ...
  22. (4*argc)(sp) NULL
  23. (4*(argc+1))(sp) envp[0]
  24. ...
  25. NULL
  26. */
  27. /*
  28. In our entry point we should save pointers to cmd line arguments
  29. and environment vars, then pass control to libc startup code.
  30. It will call "PASCALMAIN" via alias "main".
  31. */
  32. .text
  33. .globl _fpc_start
  34. .type _fpc_start,#function
  35. _fpc_start:
  36. /* Clear the frame pointer since this is the outermost frame. */
  37. mov fp, #0
  38. /* Save initial stackpointer */
  39. ldr ip,=__stkptr
  40. str sp,[ip]
  41. mov r4,sp
  42. /* Pop argc off the stack and save a pointer to argv */
  43. ldmia r4!, {r5}
  44. ldr ip,=operatingsystem_parameter_argc
  45. str r5,[ip]
  46. ldr ip,=operatingsystem_parameter_argv
  47. str r4,[ip]
  48. /* calc envp */
  49. add r5,r5,#1
  50. add r5,r4,r5,LSL #2
  51. ldr ip,=operatingsystem_parameter_envp
  52. str r5,[ip]
  53. /* Finally go to libc startup code. It will call "PASCALMAIN" via alias "main" */
  54. b _start
  55. /* --------------------------------------------------------- */
  56. .globl _haltproc
  57. .type _haltproc,#function
  58. _haltproc:
  59. .globl _haltproc_eabi
  60. .type _haltproc_eabi,#function
  61. _haltproc_eabi:
  62. ldr r0,=operatingsystem_result
  63. ldr r0,[r0]
  64. /* Go to libc exit() */
  65. b exit
  66. /* --------------------------------------------------------- */
  67. .data
  68. /* Define a symbol for the first piece of initialized data. */
  69. .globl __data_start
  70. __data_start:
  71. .long 0
  72. .weak data_start
  73. data_start = __data_start
  74. /* --------------------------------------------------------- */
  75. .bss
  76. .comm __stkptr,4
  77. .comm operatingsystem_parameter_envp,4
  78. .comm operatingsystem_parameter_argc,4
  79. .comm operatingsystem_parameter_argv,4