blob: eae68ee96355e97cb580ba440e0b781681631fc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
extern "C" {
void __declspec(naked) _switchStackInternal(void* to, void** from)
{
__asm {
// save callee-saved registers
PUSH EBP
MOV EBP, ESP
PUSH EBX
PUSH ESI
PUSH EDI
// store SIMD floating point control word
SUB ESP, 4
STMXCSR [ESP]
// store floating point control bytes
SUB ESP, 4
FSTCW [ESP]
// save the old stack pointer
MOV EDX, dword ptr 12[EBP]
MOV [EDX], ESP
// set the new stack pointer
MOV ESP, dword ptr 8[EBP]
// restore floating point control bytes
FNCLEX
FLDCW [ESP]
ADD ESP, 4
// restore SIMD floating point control word
LDMXCSR [ESP]
ADD ESP, 4
// pop callee-saved registers
POP EDI
POP ESI
POP EBX
POP EBP
RET
}
}
}
|