prt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2009 by Michael Van Canneyt and David Zhang
  4. Startup code for elf32-mipsel
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. */
  11. .section ".text"
  12. .align 4
  13. .global _dynamic_start
  14. .type _dynamic_start,#function
  15. _dynamic_start:
  16. /* TODO: need to set __dl_fini here */
  17. b _start
  18. .align 4
  19. .global _start
  20. .type _start,#function
  21. _start:
  22. 0: 03a0f021 move s8,sp
  23. 4: 2401fff8 li at,-8
  24. 8: 03a1e824 and sp,sp,at
  25. c: 27bdffe0 addiu sp,sp,-32
  26. 10: 3c17003d lui s7,0x3d
  27. 14: 26f70900 addiu s7,s7,2304
  28. 18: 2401fff8 li at,-8
  29. 1c: 02e1b824 and s7,s7,at
  30. 20: 26f7ffe0 addiu s7,s7,-32
  31. 24: 8fc40000 lw a0,0(s8)
  32. 28: 3c050000 lui a1,0x0
  33. 2c: aca40000 sw a0,0(a1)
  34. 30: 27c50004 addiu a1,s8,4
  35. 34: 3c060000 lui a2,0x0
  36. 38: acc50000 sw a1,0(a2)
  37. 3c: 24860001 addiu a2,a0,1
  38. 40: 00063080 sll a2,a2,0x2
  39. 44: 00c53021 addu a2,a2,a1
  40. 48: 3c070000 lui a3,0x0
  41. 4c: 0c000000 jal 0 <__start>
  42. 50: ace60000 sw a2,0(a3)
  43. 54: 00000000 nop
  44. /* Terminate the stack frame, and reserve space for functions to
  45. drop their arguments. */
  46. mov %g0, %fp
  47. sub %sp, 6*4, %sp
  48. /* Extract the arguments and environment as encoded on the stack. The
  49. argument info starts after one register window (16 words) past the SP. */
  50. ld [%sp+22*4], %o2
  51. sethi %hi(operatingsystem_parameter_argc),%o1
  52. or %o1,%lo(operatingsystem_parameter_argc),%o1
  53. st %o2, [%o1]
  54. add %sp, 23*4, %o0
  55. sethi %hi(operatingsystem_parameter_argv),%o1
  56. or %o1,%lo(operatingsystem_parameter_argv),%o1
  57. st %o0, [%o1]
  58. /* envp=(argc+1)*4+argv */
  59. inc %o2
  60. sll %o2, 2, %o2
  61. add %o2, %o0, %o2
  62. sethi %hi(operatingsystem_parameter_envp),%o1
  63. or %o1,%lo(operatingsystem_parameter_envp),%o1
  64. st %o2, [%o1]
  65. /* Save initial stackpointer */
  66. sethi %hi(__stkptr),%o1
  67. or %o1,%lo(__stkptr),%o1
  68. st %sp, [%o1]
  69. /* Call the user program entry point. */
  70. call PASCALMAIN
  71. nop
  72. .globl _haltproc
  73. .type _haltproc,@function
  74. _haltproc:
  75. /* TODO: need to check whether __dl_fini is non-zero and call the function pointer in case */
  76. li v0,4001
  77. lui a0,0x0
  78. lw a0,0(a0)
  79. syscall
  80. b _haltproc
  81. nop
  82. .size _start, .-_start
  83. .comm __stkptr,4
  84. .comm __dl_fini,4
  85. .comm operatingsystem_parameter_envp,4
  86. .comm operatingsystem_parameter_argc,4
  87. .comm operatingsystem_parameter_argv,4