prt0.as 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 2005 by Karoly Balogh
  4. #
  5. # Startup code for AmigaOS/PowerPC RTL
  6. #
  7. # See the file COPYING.FPC, included in this distribution,
  8. # for details about the copyright.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. .section ".text"
  15. .globl _start
  16. .align 4
  17. _start:
  18. mflr 0
  19. stw 0,4(1)
  20. stwu 1,-16(1)
  21. # Get ExecBase
  22. lwz 3,4(0)
  23. lis 4,_ExecBase@ha
  24. stw 3,_ExecBase@l(4)
  25. # Get Exec Main Interface
  26. lwz 5,632(3) # MainInterface
  27. lis 6,_IExec@ha
  28. stw 5,_IExec@l(6)
  29. # Make use of stack cookie, to avoid
  30. # stripping the symbol in all cases
  31. lis 6,__stack_cookie@ha
  32. # Store start of stack area
  33. mr 6,1
  34. addi 6,6,16
  35. lis 4,stackArea@ha
  36. stw 6,stackArea@l(4)
  37. # Store regs
  38. stwu 1,-128(1)
  39. stw 13,52(1)
  40. stw 14,56(1)
  41. stw 15,60(1)
  42. stw 16,64(1)
  43. stw 17,68(1)
  44. stw 18,72(1)
  45. stw 19,76(1)
  46. stw 20,80(1)
  47. stw 21,84(1)
  48. stw 22,88(1)
  49. stw 23,92(1)
  50. stw 24,96(1)
  51. stw 25,100(1)
  52. stw 26,104(1)
  53. stw 27,108(1)
  54. stw 28,112(1)
  55. stw 29,116(1)
  56. stw 30,120(1)
  57. stw 31,124(1)
  58. # Save Stackpointer
  59. lis 4,OriginalStkPtr@ha
  60. stw 1,OriginalStkPtr@l(4)
  61. bl PASCALMAIN
  62. .globl _haltproc
  63. _haltproc:
  64. # Restore Stackpointer
  65. lis 4,OriginalStkPtr@ha
  66. lwz 1,OriginalStkPtr@l(4)
  67. lwz 13,52(1)
  68. lwz 14,56(1)
  69. lwz 15,60(1)
  70. lwz 16,64(1)
  71. lwz 17,68(1)
  72. lwz 18,72(1)
  73. lwz 19,76(1)
  74. lwz 20,80(1)
  75. lwz 21,84(1)
  76. lwz 22,88(1)
  77. lwz 23,92(1)
  78. lwz 24,96(1)
  79. lwz 25,100(1)
  80. lwz 26,104(1)
  81. lwz 27,108(1)
  82. lwz 28,112(1)
  83. lwz 29,116(1)
  84. lwz 30,120(1)
  85. lwz 31,124(1)
  86. addi 1,1,128
  87. _exit:
  88. addi 1,1,16
  89. lwz 0,4(1)
  90. mtlr 0
  91. blr
  92. .section .data
  93. .globl _data_start
  94. _data_start:
  95. .globl _ExecBase
  96. .globl SysBase
  97. .align 4
  98. SysBase:
  99. _ExecBase:
  100. .long 0
  101. .globl _IExec
  102. .align 4
  103. _IExec:
  104. .long 0
  105. .globl OriginalStkPtr
  106. .align 4
  107. OriginalStkPtr:
  108. .long 0
  109. .globl stackArea
  110. .align 4
  111. stackArea:
  112. .long 0
  113. # This is needed to be a proper Amiga OS4 executable
  114. # This symbol _MUST NOT_ stripped out from the executable
  115. # or else...
  116. .globl __amigaos4__
  117. .type __amigaos4__,@object
  118. .size __amigaos4__,4
  119. __amigaos4__:
  120. .long 1