ontop_i386_sysv_macho_gas.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
  15. * ---------------------------------------------------------------------------------- *
  16. * ---------------------------------------------------------------------------------- *
  17. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  18. * ---------------------------------------------------------------------------------- *
  19. * | 0x20 | | *
  20. * ---------------------------------------------------------------------------------- *
  21. * | data | | *
  22. * ---------------------------------------------------------------------------------- *
  23. * *
  24. ****************************************************************************************/
  25. .text
  26. .globl _ontop_fcontext
  27. .align 2
  28. _ontop_fcontext:
  29. leal -0x18(%esp), %esp /* prepare stack */
  30. #if !defined(BOOST_USE_TSX)
  31. stmxcsr (%esp) /* save MMX control- and status-word */
  32. fnstcw 0x4(%esp) /* save x87 control-word */
  33. #endif
  34. movl %edi, 0x8(%esp) /* save EDI */
  35. movl %esi, 0xc(%esp) /* save ESI */
  36. movl %ebx, 0x10(%esp) /* save EBX */
  37. movl %ebp, 0x14(%esp) /* save EBP */
  38. /* store ESP (pointing to context-data) in ECX */
  39. movl %esp, %ecx
  40. /* first arg of ontop_fcontext() == fcontext to jump to */
  41. movl 0x1c(%esp), %eax
  42. /* pass parent fcontext_t */
  43. movl %ecx, 0x1c(%eax)
  44. /* second arg of ontop_fcontext() == data to be transferred */
  45. movl 0x20(%esp), %ecx
  46. /* pass data */
  47. movl %ecx, 0x20(%eax)
  48. /* third arg of ontop_fcontext() == ontop-function */
  49. movl 0x24(%esp), %ecx
  50. /* restore ESP (pointing to context-data) from EAX */
  51. movl %eax, %esp
  52. /* return parent fcontext_t */
  53. movl %ecx, %eax
  54. /* returned data is stored in EDX */
  55. #if !defined(BOOST_USE_TSX)
  56. ldmxcsr (%esp) /* restore MMX control- and status-word */
  57. fldcw 0x4(%esp) /* restore x87 control-word */
  58. #endif
  59. movl 0x8(%esp), %edi /* restore EDI */
  60. movl 0xc(%esp), %esi /* restore ESI */
  61. movl 0x10(%esp), %ebx /* restore EBX */
  62. movl 0x14(%esp), %ebp /* restore EBP */
  63. leal 0x18(%esp), %esp /* prepare stack */
  64. /* jump to context */
  65. jmp *%ecx