1 | ; $Id: setjmp.asm 8259 2008-04-21 21:01:41Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; IPRT - No-CRT setjmp & longjmp - AMD64 & X86.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; The contents of this file may alternatively be used under the terms
|
---|
18 | ; of the Common Development and Distribution License Version 1.0
|
---|
19 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | ; CDDL are applicable instead of those of the GPL.
|
---|
22 | ;
|
---|
23 | ; You may elect to license modified versions of this file under the
|
---|
24 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | ;
|
---|
26 | ; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | ; Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | ; additional information or have any questions.
|
---|
29 | ;
|
---|
30 |
|
---|
31 | %include "iprt/asmdefs.mac"
|
---|
32 |
|
---|
33 |
|
---|
34 | BEGINCODE
|
---|
35 |
|
---|
36 |
|
---|
37 | BEGINPROC RT_NOCRT(setjmp)
|
---|
38 | %ifdef RT_ARCH_AMD64
|
---|
39 | mov rax, [rsp]
|
---|
40 | mov [rdi + 00h], rax ; rip
|
---|
41 | lea rcx, [rsp + 8]
|
---|
42 | mov [rdi + 08h], rcx ; rsp
|
---|
43 | mov [rdi + 10h], rbp
|
---|
44 | mov [rdi + 18h], r15
|
---|
45 | mov [rdi + 20h], r14
|
---|
46 | mov [rdi + 28h], r13
|
---|
47 | mov [rdi + 30h], r12
|
---|
48 | mov [rdi + 38h], rbx
|
---|
49 | %else
|
---|
50 | mov edx, [esp + 4h]
|
---|
51 | mov eax, [esp]
|
---|
52 | mov [edx + 00h], eax ; eip
|
---|
53 | lea ecx, [esp + 4h]
|
---|
54 | mov [edx + 04h], ecx ; esp
|
---|
55 | mov [edx + 08h], ebp
|
---|
56 | mov [edx + 0ch], ebx
|
---|
57 | mov [edx + 10h], edi
|
---|
58 | mov [edx + 14h], esi
|
---|
59 | %endif
|
---|
60 | xor eax, eax
|
---|
61 | ret
|
---|
62 | ENDPROC RT_NOCRT(setjmp)
|
---|
63 |
|
---|
64 |
|
---|
65 | BEGINPROC RT_NOCRT(longjmp)
|
---|
66 | %ifdef RT_ARCH_AMD64
|
---|
67 | mov rbx, [rdi + 38h]
|
---|
68 | mov r12, [rdi + 30h]
|
---|
69 | mov r13, [rdi + 28h]
|
---|
70 | mov r14, [rdi + 20h]
|
---|
71 | mov r15, [rdi + 18h]
|
---|
72 | mov rbp, [rdi + 10h]
|
---|
73 | mov eax, esi
|
---|
74 | test eax, eax
|
---|
75 | jnz .fine
|
---|
76 | inc al
|
---|
77 | .fine:
|
---|
78 | mov rsp, [rdi + 08h]
|
---|
79 | jmp qword [rdi + 00h]
|
---|
80 | %else
|
---|
81 | mov edx, [esp + 4h]
|
---|
82 | mov eax, [esp + 8h]
|
---|
83 | mov esi, [edx + 14h]
|
---|
84 | mov edi, [edx + 10h]
|
---|
85 | mov ebx, [edx + 0ch]
|
---|
86 | mov ebp, [edx + 08h]
|
---|
87 | test eax, eax
|
---|
88 | jnz .fine
|
---|
89 | inc al
|
---|
90 | .fine:
|
---|
91 | mov esp, [edx + 04h]
|
---|
92 | jmp dword [edx + 00h]
|
---|
93 | %endif
|
---|
94 | ENDPROC RT_NOCRT(longjmp)
|
---|
95 |
|
---|