jump.S 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
  13. * ----------------------------------------------------------------------------------- *
  14. * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | *
  15. * ----------------------------------------------------------------------------------- *
  16. * *
  17. *****************************************************************************************/
  18. .text
  19. .globl jump_fcontext
  20. .align 2
  21. .type jump_fcontext,@function
  22. jump_fcontext:
  23. pushl %ebp /* save EBP */
  24. pushl %ebx /* save EBX */
  25. pushl %esi /* save ESI */
  26. pushl %edi /* save EDI */
  27. /* store fcontext_t in ECX */
  28. movl %esp, %ecx
  29. /* first arg of jump_fcontext() == fcontext to jump to */
  30. movl 0x18(%esp), %eax
  31. /* second arg of jump_fcontext() == data to be transferred */
  32. movl 0x1c(%esp), %edx
  33. /* restore ESP (pointing to context-data) from EAX */
  34. movl %eax, %esp
  35. /* address of returned transport_t */
  36. movl 0x14(%esp), %eax
  37. /* return parent fcontext_t */
  38. movl %ecx, (%eax)
  39. /* return data */
  40. movl %edx, 0x4(%eax)
  41. popl %edi /* restore EDI */
  42. popl %esi /* restore ESI */
  43. popl %ebx /* restore EBX */
  44. popl %ebp /* restore EBP */
  45. /* jump to context */
  46. ret $4
  47. .size jump_fcontext,.-jump_fcontext
  48. /* Mark that we don't need executable stack. */
  49. .section .note.GNU-stack,"",%progbits