make_mips32_o32_elf_gas.S 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. .text
  26. .globl make_fcontext
  27. .align 2
  28. .type make_fcontext,@function
  29. .ent make_fcontext
  30. make_fcontext:
  31. #ifdef __PIC__
  32. .set noreorder
  33. .cpload $t9
  34. .set reorder
  35. #endif
  36. # first arg of make_fcontext() == top address of context-stack
  37. move $v0, $a0
  38. # shift address in A0 to lower 16 byte boundary
  39. move $v1, $v0
  40. li $v0, -16 # 0xfffffffffffffff0
  41. and $v0, $v1, $v0
  42. # reserve space for context-data on context-stack
  43. # including 48 byte of shadow space (sp % 16 == 0)
  44. addiu $v0, $v0, -112
  45. # third arg of make_fcontext() == address of context-function
  46. sw $a2, 44($v0)
  47. # save global pointer in context-data
  48. sw $gp, 48($v0)
  49. # compute address of returned transfer_t
  50. addiu $t0, $v0, 52
  51. sw $t0, 36($v0)
  52. # compute abs address of label finish
  53. la $t9, finish
  54. # save address of finish as return-address for context-function
  55. # will be entered after context-function returns
  56. sw $t9, 40($v0)
  57. jr $ra # return pointer to context-data
  58. finish:
  59. lw $gp, 0($sp)
  60. # allocate stack space (contains shadow space for subroutines)
  61. addiu $sp, $sp, -32
  62. # save return address
  63. sw $ra, 28($sp)
  64. # restore GP (global pointer)
  65. # move $gp, $s1
  66. # exit code is zero
  67. move $a0, $zero
  68. # address of exit
  69. lw $t9, %call16(_exit)($gp)
  70. # exit application
  71. jalr $t9
  72. .end make_fcontext
  73. .size make_fcontext, .-make_fcontext
  74. /* Mark that we don't need executable stack. */
  75. .section .note.GNU-stack,"",%progbits