make_mips32_o32_elf_gas.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | *
  15. * ------------------------------------------------- *
  16. * ------------------------------------------------- *
  17. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  18. * ------------------------------------------------- *
  19. * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
  20. * ------------------------------------------------- *
  21. * | FP |hiddn| RA | PC | GP | FCTX| DATA| | *
  22. * ------------------------------------------------- *
  23. * *
  24. * *****************************************************/
  25. /*******************************************************
  26. * *
  27. * ------------------------------------------------- *
  28. * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
  29. * ------------------------------------------------- *
  30. * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
  31. * ------------------------------------------------- *
  32. * | F20 | F22 | F24 | F26 | *
  33. * ------------------------------------------------- *
  34. * ------------------------------------------------- *
  35. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  36. * ------------------------------------------------- *
  37. * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
  38. * ------------------------------------------------- *
  39. * | F28 | F30 | S0 | S1 | S2 | S3 | *
  40. * ------------------------------------------------- *
  41. * ------------------------------------------------- *
  42. * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
  43. * ------------------------------------------------- *
  44. * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
  45. * ------------------------------------------------- *
  46. * | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | *
  47. * ------------------------------------------------- *
  48. * ------------------------------------------------- *
  49. * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
  50. * ------------------------------------------------- *
  51. * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
  52. * ------------------------------------------------- *
  53. * | GP | FCTX| DATA| | | | | | *
  54. * ------------------------------------------------- *
  55. * *
  56. * *****************************************************/
  57. .text
  58. .globl make_fcontext
  59. .align 2
  60. .type make_fcontext,@function
  61. .ent make_fcontext
  62. make_fcontext:
  63. #ifdef __PIC__
  64. .set noreorder
  65. .cpload $t9
  66. .set reorder
  67. #endif
  68. # first arg of make_fcontext() == top address of context-stack
  69. move $v0, $a0
  70. # shift address in A0 to lower 16 byte boundary
  71. move $v1, $v0
  72. li $v0, -16 # 0xfffffffffffffff0
  73. and $v0, $v1, $v0
  74. # reserve space for context-data on context-stack
  75. # including 48 byte of shadow space (sp % 16 == 0)
  76. addiu $v0, $v0, -112
  77. # third arg of make_fcontext() == address of context-function
  78. sw $a2, 92($v0)
  79. # save global pointer in context-data
  80. sw $gp, 96($v0)
  81. # compute address of returned transfer_t
  82. addiu $t0, $v0, 52
  83. sw $t0, 84($v0)
  84. # compute abs address of label finish
  85. la $t9, finish
  86. # save address of finish as return-address for context-function
  87. # will be entered after context-function returns
  88. sw $t9, 88($v0)
  89. jr $ra # return pointer to context-data
  90. finish:
  91. lw $gp, 0($sp)
  92. # allocate stack space (contains shadow space for subroutines)
  93. addiu $sp, $sp, -32
  94. # save return address
  95. sw $ra, 28($sp)
  96. # restore GP (global pointer)
  97. # move $gp, $s1
  98. # exit code is zero
  99. move $a0, $zero
  100. # address of exit
  101. lw $t9, %call16(_exit)($gp)
  102. # exit application
  103. jalr $t9
  104. .end make_fcontext
  105. .size make_fcontext, .-make_fcontext
  106. /* Mark that we don't need executable stack. */
  107. .section .note.GNU-stack,"",%progbits