2
0

prt0.as 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ldr ip,=_start
  55. bx ip
  56. /* --------------------------------------------------------- */
  57. .globl _haltproc
  58. .type _haltproc,#function
  59. _haltproc:
  60. .globl _haltproc_eabi
  61. .type _haltproc_eabi,#function
  62. _haltproc_eabi:
  63. ldr r0,=operatingsystem_result
  64. ldr r0,[r0]
  65. /* Go to libc exit() */
  66. ldr ip,=exit
  67. bx ip
  68. /* --------------------------------------------------------- */
  69. .data
  70. /* Define a symbol for the first piece of initialized data. */
  71. .globl __data_start
  72. __data_start:
  73. .long 0
  74. .weak data_start
  75. data_start = __data_start
  76. /* --------------------------------------------------------- */
  77. .bss
  78. .comm __stkptr,4
  79. .comm operatingsystem_parameter_envp,4
  80. .comm operatingsystem_parameter_argc,4
  81. .comm operatingsystem_parameter_argv,4