diff options
author | Christian Kamm <[email protected]> | 2010-02-26 13:57:50 +0100 |
---|---|---|
committer | Christian Kamm <[email protected]> | 2010-02-26 13:57:50 +0100 |
commit | 9a52f0dd19a1d3314b435fade0a5338609e838a1 (patch) | |
tree | 9be84e54fdc7b375b2778705659176d6ecbfc6b5 /library/fibers/switchstack_msvc_32.cpp | |
parent | 754a63ff40fd78be7bc0bf70c8b072d079e1fac9 (diff) |
Diffstat (limited to 'library/fibers/switchstack_msvc_32.cpp')
-rw-r--r-- | library/fibers/switchstack_msvc_32.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/library/fibers/switchstack_msvc_32.cpp b/library/fibers/switchstack_msvc_32.cpp new file mode 100644 index 0000000..eae68ee --- /dev/null +++ b/library/fibers/switchstack_msvc_32.cpp @@ -0,0 +1,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 + } +} +} |