jump_mips32_o32_elf_gas.S 4.1 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. * | F20 | F22 | F24 | F26 | *
  15. * ------------------------------------------------- *
  16. * ------------------------------------------------- *
  17. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  18. * ------------------------------------------------- *
  19. * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
  20. * ------------------------------------------------- *
  21. * | F28 | F30 | S0 | S1 | S2 | S3 | *
  22. * ------------------------------------------------- *
  23. * ------------------------------------------------- *
  24. * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
  25. * ------------------------------------------------- *
  26. * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
  27. * ------------------------------------------------- *
  28. * | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | *
  29. * ------------------------------------------------- *
  30. * ------------------------------------------------- *
  31. * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
  32. * ------------------------------------------------- *
  33. * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
  34. * ------------------------------------------------- *
  35. * | GP | FCTX| DATA| | | | | | *
  36. * ------------------------------------------------- *
  37. * *
  38. * *****************************************************/
  39. .text
  40. .globl jump_fcontext
  41. .align 2
  42. .type jump_fcontext,@function
  43. .ent jump_fcontext
  44. jump_fcontext:
  45. # reserve space on stack
  46. addiu $sp, $sp, -96
  47. sw $s0, 48($sp) # save S0
  48. sw $s1, 52($sp) # save S1
  49. sw $s2, 56($sp) # save S2
  50. sw $s3, 60($sp) # save S3
  51. sw $s4, 64($sp) # save S4
  52. sw $s5, 68($sp) # save S5
  53. sw $s6, 72($sp) # save S6
  54. sw $s7, 76($sp) # save S7
  55. sw $fp, 80($sp) # save FP
  56. sw $a0, 84($sp) # save hidden, address of returned transfer_t
  57. sw $ra, 88($sp) # save RA
  58. sw $ra, 92($sp) # save RA as PC
  59. #if defined(__mips_hard_float)
  60. s.d $f20, ($sp) # save F20
  61. s.d $f22, 8($sp) # save F22
  62. s.d $f24, 16($sp) # save F24
  63. s.d $f26, 24($sp) # save F26
  64. s.d $f28, 32($sp) # save F28
  65. s.d $f30, 40($sp) # save F30
  66. #endif
  67. # store SP (pointing to context-data) in A0
  68. move $a0, $sp
  69. # restore SP (pointing to context-data) from A1
  70. move $sp, $a1
  71. #if defined(__mips_hard_float)
  72. l.d $f20, ($sp) # restore F20
  73. l.d $f22, 8($sp) # restore F22
  74. l.d $f24, 16($sp) # restore F24
  75. l.d $f26, 24($sp) # restore F26
  76. l.d $f28, 32($sp) # restore F28
  77. l.d $f30, 40($sp) # restore F30
  78. #endif
  79. lw $s0, 48($sp) # restore S0
  80. lw $s1, 52($sp) # restore S1
  81. lw $s2, 56($sp) # restore S2
  82. lw $s3, 60($sp) # restore S3
  83. lw $s4, 64($sp) # restore S4
  84. lw $s5, 68($sp) # restore S5
  85. lw $s6, 72($sp) # restore S6
  86. lw $s7, 76($sp) # restore S7
  87. lw $fp, 80($sp) # restore FP
  88. lw $t0, 84($sp) # restore hidden, address of returned transfer_t
  89. lw $ra, 88($sp) # restore RA
  90. # load PC
  91. lw $t9, 92($sp)
  92. # adjust stack
  93. addiu $sp, $sp, 96
  94. # return transfer_t from jump
  95. sw $a0, ($t0) # fctx of transfer_t
  96. sw $a2, 4($t0) # data of transfer_t
  97. # pass transfer_t as first arg in context function
  98. # A0 == fctx, A1 == data
  99. move $a1, $a2
  100. # jump to context
  101. jr $t9
  102. .end jump_fcontext
  103. .size jump_fcontext, .-jump_fcontext
  104. /* Mark that we don't need executable stack. */
  105. .section .note.GNU-stack,"",%progbits