]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | |
9 | ; --------------------------------------------------------------------------------- | |
10 | ; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | | |
11 | ; --------------------------------------------------------------------------------- | |
b32b8144 | 12 | ; | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | |
7c673cae FG |
13 | ; --------------------------------------------------------------------------------- |
14 | ; --------------------------------------------------------------------------------- | |
15 | ; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | |
16 | ; --------------------------------------------------------------------------------- | |
17 | ; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | | |
18 | ; --------------------------------------------------------------------------------- | |
b32b8144 | 19 | ; | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| |
7c673cae FG |
20 | ; --------------------------------------------------------------------------------- |
21 | ||
22 | .386 | |
23 | .XMM | |
24 | .model flat, c | |
25 | .code | |
26 | ||
27 | jump_fcontext PROC BOOST_CONTEXT_EXPORT | |
b32b8144 FG |
28 | ; prepare stack |
29 | lea esp, [esp-02ch] | |
30 | ||
31 | IFNDEF BOOST_USE_TSX | |
32 | ; save MMX control- and status-word | |
33 | stmxcsr [esp] | |
34 | ; save x87 control-word | |
35 | fnstcw [esp+04h] | |
36 | ENDIF | |
7c673cae FG |
37 | |
38 | assume fs:nothing | |
39 | ; load NT_TIB into ECX | |
40 | mov edx, fs:[018h] | |
41 | assume fs:error | |
b32b8144 FG |
42 | ; load fiber local storage |
43 | mov eax, [edx+010h] | |
44 | mov [esp+08h], eax | |
7c673cae FG |
45 | ; load current deallocation stack |
46 | mov eax, [edx+0e0ch] | |
b32b8144 FG |
47 | mov [esp+0ch], eax |
48 | ; load current stack limit | |
49 | mov eax, [edx+08h] | |
50 | mov [esp+010h], eax | |
51 | ; load current stack base | |
52 | mov eax, [edx+04h] | |
53 | mov [esp+014h], eax | |
54 | ; load current SEH exception list | |
55 | mov eax, [edx] | |
56 | mov [esp+018h], eax | |
7c673cae | 57 | |
b32b8144 FG |
58 | mov [esp+01ch], edi ; save EDI |
59 | mov [esp+020h], esi ; save ESI | |
60 | mov [esp+024h], ebx ; save EBX | |
61 | mov [esp+028h], ebp ; save EBP | |
7c673cae FG |
62 | |
63 | ; store ESP (pointing to context-data) in EAX | |
64 | mov eax, esp | |
65 | ||
66 | ; firstarg of jump_fcontext() == fcontext to jump to | |
b32b8144 | 67 | mov ecx, [esp+030h] |
7c673cae | 68 | |
b32b8144 | 69 | ; restore ESP (pointing to context-data) from ECX |
7c673cae FG |
70 | mov esp, ecx |
71 | ||
b32b8144 FG |
72 | IFNDEF BOOST_USE_TSX |
73 | ; restore MMX control- and status-word | |
74 | ldmxcsr [esp] | |
75 | ; restore x87 control-word | |
76 | fldcw [esp+04h] | |
77 | ENDIF | |
78 | ||
7c673cae FG |
79 | assume fs:nothing |
80 | ; load NT_TIB into EDX | |
81 | mov edx, fs:[018h] | |
82 | assume fs:error | |
7c673cae | 83 | ; restore fiber local storage |
b32b8144 | 84 | mov ecx, [esp+08h] |
7c673cae | 85 | mov [edx+010h], ecx |
7c673cae | 86 | ; restore current deallocation stack |
b32b8144 | 87 | mov ecx, [esp+0ch] |
7c673cae | 88 | mov [edx+0e0ch], ecx |
7c673cae | 89 | ; restore current stack limit |
b32b8144 | 90 | mov ecx, [esp+010h] |
7c673cae | 91 | mov [edx+08h], ecx |
7c673cae | 92 | ; restore current stack base |
b32b8144 | 93 | mov ecx, [esp+014h] |
7c673cae | 94 | mov [edx+04h], ecx |
7c673cae | 95 | ; restore current SEH exception list |
b32b8144 | 96 | mov ecx, [esp+018h] |
7c673cae FG |
97 | mov [edx], ecx |
98 | ||
b32b8144 FG |
99 | mov ecx, [esp+02ch] ; restore EIP |
100 | ||
101 | mov edi, [esp+01ch] ; restore EDI | |
102 | mov esi, [esp+020h] ; restore ESI | |
103 | mov ebx, [esp+024h] ; restore EBX | |
104 | mov ebp, [esp+028h] ; restore EBP | |
105 | ||
106 | ; prepare stack | |
107 | lea esp, [esp+030h] | |
7c673cae FG |
108 | |
109 | ; return transfer_t | |
110 | ; FCTX == EAX, DATA == EDX | |
b32b8144 | 111 | mov edx, [eax+034h] |
7c673cae FG |
112 | |
113 | ; jump to context | |
b32b8144 | 114 | jmp ecx |
7c673cae FG |
115 | jump_fcontext ENDP |
116 | END |