prt0.as 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 _start
  14. .type _start,#function
  15. _start:
  16. 0: 03a0f021 move s8,sp
  17. 4: 2401fff8 li at,-8
  18. 8: 03a1e824 and sp,sp,at
  19. c: 27bdffe0 addiu sp,sp,-32
  20. 10: 3c17003d lui s7,0x3d
  21. 14: 26f70900 addiu s7,s7,2304
  22. 18: 2401fff8 li at,-8
  23. 1c: 02e1b824 and s7,s7,at
  24. 20: 26f7ffe0 addiu s7,s7,-32
  25. 24: 8fc40000 lw a0,0(s8)
  26. 28: 3c050000 lui a1,0x0
  27. 2c: aca40000 sw a0,0(a1)
  28. 30: 27c50004 addiu a1,s8,4
  29. 34: 3c060000 lui a2,0x0
  30. 38: acc50000 sw a1,0(a2)
  31. 3c: 24860001 addiu a2,a0,1
  32. 40: 00063080 sll a2,a2,0x2
  33. 44: 00c53021 addu a2,a2,a1
  34. 48: 3c070000 lui a3,0x0
  35. 4c: 0c000000 jal 0 <__start>
  36. 50: ace60000 sw a2,0(a3)
  37. 54: 00000000 nop
  38. /* Terminate the stack frame, and reserve space for functions to
  39. drop their arguments. */
  40. mov %g0, %fp
  41. sub %sp, 6*4, %sp
  42. /* Extract the arguments and environment as encoded on the stack. The
  43. argument info starts after one register window (16 words) past the SP. */
  44. ld [%sp+22*4], %o2
  45. sethi %hi(operatingsystem_parameter_argc),%o1
  46. or %o1,%lo(operatingsystem_parameter_argc),%o1
  47. st %o2, [%o1]
  48. add %sp, 23*4, %o0
  49. sethi %hi(operatingsystem_parameter_argv),%o1
  50. or %o1,%lo(operatingsystem_parameter_argv),%o1
  51. st %o0, [%o1]
  52. /* envp=(argc+1)*4+argv */
  53. inc %o2
  54. sll %o2, 2, %o2
  55. add %o2, %o0, %o2
  56. sethi %hi(operatingsystem_parameter_envp),%o1
  57. or %o1,%lo(operatingsystem_parameter_envp),%o1
  58. st %o2, [%o1]
  59. /* Save initial stackpointer */
  60. sethi %hi(__stkptr),%o1
  61. or %o1,%lo(__stkptr),%o1
  62. st %sp, [%o1]
  63. /* Call the user program entry point. */
  64. call PASCALMAIN
  65. nop
  66. .globl _haltproc
  67. .type _haltproc,@function
  68. _haltproc:
  69. li v0,4001
  70. lui a0,0x0
  71. lw a0,0(a0)
  72. syscall
  73. b _haltproc
  74. nop
  75. .size _start, .-_start
  76. .comm __stkptr,4
  77. .comm operatingsystem_parameter_envp,4
  78. .comm operatingsystem_parameter_argc,4
  79. .comm operatingsystem_parameter_argv,4