make_ppc32_sysv_xcoff_gas.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. Copyright Oliver Kowalke 2009.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /******************************************************
  8. * *
  9. * ------------------------------------------------- *
  10. * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
  11. * ------------------------------------------------- *
  12. * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
  13. * ------------------------------------------------- *
  14. * | F14 | F15 | F16 | F17 | *
  15. * ------------------------------------------------- *
  16. * ------------------------------------------------- *
  17. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  18. * ------------------------------------------------- *
  19. * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
  20. * ------------------------------------------------- *
  21. * | F18 | F19 | F20 | F21 | *
  22. * ------------------------------------------------- *
  23. * ------------------------------------------------- *
  24. * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
  25. * ------------------------------------------------- *
  26. * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
  27. * ------------------------------------------------- *
  28. * | F22 | F23 | F24 | F25 | *
  29. * ------------------------------------------------- *
  30. * ------------------------------------------------- *
  31. * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
  32. * ------------------------------------------------- *
  33. * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
  34. * ------------------------------------------------- *
  35. * | F26 | F27 | F28 | F29 | *
  36. * ------------------------------------------------- *
  37. * ------------------------------------------------- *
  38. * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
  39. * ------------------------------------------------- *
  40. * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
  41. * ------------------------------------------------- *
  42. * | F30 | F31 | fpscr | R13 | R14 | *
  43. * ------------------------------------------------- *
  44. * ------------------------------------------------- *
  45. * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
  46. * ------------------------------------------------- *
  47. * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
  48. * ------------------------------------------------- *
  49. * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | *
  50. * ------------------------------------------------- *
  51. * ------------------------------------------------- *
  52. * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
  53. * ------------------------------------------------- *
  54. * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
  55. * ------------------------------------------------- *
  56. * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | *
  57. * ------------------------------------------------- *
  58. * ------------------------------------------------- *
  59. * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
  60. * ------------------------------------------------- *
  61. * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
  62. * ------------------------------------------------- *
  63. * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| *
  64. * ------------------------------------------------- *
  65. * ------------------------------------------------- *
  66. * | 64 | | *
  67. * ------------------------------------------------- *
  68. * | 256 | | *
  69. * ------------------------------------------------- *
  70. * | DATA| | *
  71. * ------------------------------------------------- *
  72. * *
  73. *******************************************************/
  74. .globl make_fcontext[DS]
  75. .globl .make_fcontext[PR]
  76. .align 2
  77. .csect make_fcontext[DS]
  78. make_fcontext:
  79. .long .make_fcontext[PR]
  80. .csect .make_fcontext[PR], 3
  81. #.make_fcontext:
  82. # save return address into R6
  83. mflr 6
  84. # first arg of make_fcontext() == top address of context-function
  85. # shift address in R3 to lower 16 byte boundary
  86. clrrwi 3, 3, 4
  87. # reserve space for context-data on context-stack
  88. # including 64 byte of linkage + parameter area (R1 % 16 == 0)
  89. subi 3, 3, 336
  90. # third arg of make_fcontext() == address of context-function
  91. stw 5, 240(3)
  92. # set back-chain to zero
  93. li 0, 0
  94. stw 0, 244(3)
  95. # compute address of returned transfer_t
  96. addi 0, 3, 252
  97. mr 4, 0
  98. stw 4, 228(3)
  99. # load LR
  100. mflr 0
  101. # jump to label 1
  102. bl .Label
  103. .Label:
  104. # load LR into R4
  105. mflr 4
  106. # compute abs address of label .L_finish
  107. addi 4, 4, .L_finish - .Label
  108. # restore LR
  109. mtlr 0
  110. # save address of finish as return-address for context-function
  111. # will be entered after context-function returns
  112. stw 4, 236(3)
  113. # restore return address from R6
  114. mtlr 6
  115. blr # return pointer to context-data
  116. .L_finish:
  117. # save return address into R0
  118. mflr 0
  119. # save return address on stack, set up stack frame
  120. stw 0, 4(1)
  121. # allocate stack space, R1 % 16 == 0
  122. stwu 1, -16(1)
  123. # exit code is zero
  124. li 3, 0
  125. # exit application
  126. bl ._exit
  127. nop