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_strg |fc_deallo| limit | base | fc_seh | EDI | ESI | EBX | *
16 * --------------------------------------------------------------------------------- *
17 * --------------------------------------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * --------------------------------------------------------------------------------- *
20 * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | *
21 * --------------------------------------------------------------------------------- *
22 * | EBP | EIP | to | data | | EH NXT |SEH HNDLR| | *
23 * --------------------------------------------------------------------------------- *
24 *************************************************************************************/
26 .file "ontop_i386_ms_pe_gas.asm"
29 .globl _ontop_fcontext
30 .def _ontop_fcontext; .scl 2; .type 32; .endef
32 pushl %ebp /* save EBP */
33 pushl %ebx /* save EBX */
34 pushl %esi /* save ESI */
35 pushl %edi /* save EDI */
40 /* load current SEH exception list */
44 /* load current stack base */
48 /* load current stack limit */
52 /* load current dealloction stack */
53 movl 0xe0c(%edx), %eax
56 /* load fiber local storage */
60 /* store ESP (pointing to context-data) in EAX */
63 /* first arg of ontop_fcontext() == fcontext to jump to */
66 /* pass parent fcontext_t */
69 /* second arg of ontop_fcontext() == data to be transferred */
75 /* third arg of ontop_fcontext() == ontop-function */
78 /* restore ESP (pointing to context-data) from EDX */
81 /* load NT_TIB into ECX */
84 /* restore fiber local storage */
88 /* restore current deallocation stack */
90 movl %eax, 0xe0c(%edx)
92 /* restore current stack limit */
96 /* restore current stack base */
100 /* restore current SEH exception list */
104 popl %edi /* save EDI */
105 popl %esi /* save ESI */
106 popl %ebx /* save EBX */
107 popl %ebp /* save EBP */
109 /* jump to context */
113 .ascii " -export:\"ontop_fcontext\""