Sync to Wine-20050524:
[reactos.git] / reactos / lib / pseh / i386 / setjmp.asm
1 ; Copyright (c) 2004/2005 KJK::Hyperion
2
3 ; Permission is hereby granted, free of charge, to any person obtaining a copy
4 ; of this software and associated documentation files (the "Software"), to deal
5 ; in the Software without restriction, including without limitation the rights
6 ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 ; copies of the Software, and to permit persons to whom the Software is
8 ; furnished to dos so, subject to the following conditions:
9
10 ; The above copyright notice and this permission notice shall be included in all
11 ; copies or substantial portions of the Software.
12
13 ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 ; SOFTWARE.
20
21 segment .text use32
22
23 ; Note: the undecorated names are for Borland C++ (and possibly other compilers
24 ; using the OMF format)
25 global SEHSetJmp
26 global __SEHSetJmp@4
27 SEHSetJmp:
28 __SEHSetJmp@4:
29 ; jump buffer
30 mov eax, [esp+4]
31
32 ; program counter
33 mov ecx, [esp+0]
34
35 ; stack pointer
36 lea edx, [esp+4]
37
38 ; fill the jump buffer
39 mov [eax+0], ebp
40 mov [eax+4], edx
41 mov [eax+8], ecx
42 mov [eax+12], ebx
43 mov [eax+16], esi
44 mov [eax+20], edi
45
46 xor eax, eax
47 ret 4
48
49 global SEHLongJmp
50 global __SEHLongJmp@8
51 SEHLongJmp:
52 __SEHLongJmp@8:
53 ; return value
54 mov eax, [esp+8]
55
56 ; jump buffer
57 mov ecx, [esp+4]
58
59 ; restore the saved context
60 mov ebp, [ecx+0]
61 mov esp, [ecx+4]
62 mov edx, [ecx+8]
63 mov ebx, [ecx+12]
64 mov esi, [ecx+16]
65 mov edi, [ecx+20]
66 jmp edx
67
68
69 global SEHLongJmp_KeepEsp
70 global __SEHLongJmp_KeepEsp@8
71 SEHLongJmp_KeepEsp:
72 __SEHLongJmp_KeepEsp@8:
73 ; return value
74 mov eax, [esp+8]
75
76 ; jump buffer
77 mov ecx, [esp+4]
78
79 ; restore the saved context
80 mov ebp, [ecx+0]
81 ; don't restore esp
82 ; mov esp, [ecx+4]
83 mov edx, [ecx+8]
84 mov ebx, [ecx+12]
85 mov esi, [ecx+16]
86 mov edi, [ecx+20]
87 jmp edx
88
89 ; EOF