ontop_i386_sysv_elf_gas.S 3.5 KB

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