2 Copyright Oliver Kowalke 2009.
3 Copyright Thomas Sailer 2013.
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
9 /*************************************************************************************
10 * --------------------------------------------------------------------------------- *
11 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
12 * --------------------------------------------------------------------------------- *
13 * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | *
14 * --------------------------------------------------------------------------------- *
15 * | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | *
16 * --------------------------------------------------------------------------------- *
17 * --------------------------------------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * --------------------------------------------------------------------------------- *
20 * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | *
21 * --------------------------------------------------------------------------------- *
22 * | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| *
23 * --------------------------------------------------------------------------------- *
24 **************************************************************************************/
26 .file "ontop_i386_ms_pe_gas.asm"
30 /* mark as using no unregistered SEH handlers */
32 .def @feat.00; .scl 3; .type 0; .endef
35 .globl _ontop_fcontext
36 .def _ontop_fcontext; .scl 2; .type 32; .endef
39 leal -0x2c(%esp), %esp
41 #if !defined(BOOST_USE_TSX)
42 /* save MMX control- and status-word */
44 /* save x87 control-word */
50 /* load fiber local storage */
53 /* load current dealloction stack */
54 movl 0xe0c(%edx), %eax
56 /* load current stack limit */
59 /* load current stack base */
62 /* load current SEH exception list */
66 movl %edi, 0x1c(%esp) /* save EDI */
67 movl %esi, 0x20(%esp) /* save ESI */
68 movl %ebx, 0x24(%esp) /* save EBX */
69 movl %ebp, 0x28(%esp) /* save EBP */
71 /* store ESP (pointing to context-data) in ECX */
74 /* first arg of ontop_fcontext() == fcontext to jump to */
77 /* pass parent fcontext_t */
80 /* second arg of ontop_fcontext() == data to be transferred */
86 /* third arg of ontop_fcontext() == ontop-function */
89 /* restore ESP (pointing to context-data) from EDX */
92 #if !defined(BOOST_USE_TSX)
93 /* restore MMX control- and status-word */
95 /* restore x87 control-word */
99 /* restore NT_TIB into EDX */
100 movl %fs:(0x18), %edx
101 /* restore fiber local storage */
103 movl %eax, 0x10(%edx)
104 /* restore current deallocation stack */
106 movl %eax, 0xe0c(%edx)
107 /* restore current stack limit */
108 movl 0x10(%esp), %eax
109 movl %eax, 0x08(%edx)
110 /* restore current stack base */
111 movl 0x14(%esp), %eax
112 movl %eax, 0x04(%edx)
113 /* restore current SEH exception list */
114 movl 0x18(%esp), %eax
117 movl 0x1c(%esp), %edi /* restore EDI */
118 movl 0x20(%esp), %esi /* restore ESI */
119 movl 0x24(%esp), %ebx /* restore EBX */
120 movl 0x28(%esp), %ebp /* restore EBP */
123 leal 0x2c(%esp), %esp
125 /* keep return-address on stack */
127 /* jump to context */
131 .ascii " -export:\"_ontop_fcontext\""