1 | ; $Id: setjmp.asm 5999 2007-12-07 15:05:06Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; innotek Portable Runtime - No-CRT setjmp & longjmp - AMD64 & X86.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2007 innotek GmbH
|
---|
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 |
|
---|
27 | %include "iprt/asmdefs.mac"
|
---|
28 |
|
---|
29 |
|
---|
30 | BEGINCODE
|
---|
31 |
|
---|
32 |
|
---|
33 | BEGINPROC RT_NOCRT(setjmp)
|
---|
34 | %ifdef RT_ARCH_AMD64
|
---|
35 | mov rax, [rsp]
|
---|
36 | mov [rdi + 00h], rax ; rip
|
---|
37 | lea rcx, [rsp + 8]
|
---|
38 | mov [rdi + 08h], rcx ; rsp
|
---|
39 | mov [rdi + 10h], rbp
|
---|
40 | mov [rdi + 18h], r15
|
---|
41 | mov [rdi + 20h], r14
|
---|
42 | mov [rdi + 28h], r13
|
---|
43 | mov [rdi + 30h], r12
|
---|
44 | mov [rdi + 38h], rbx
|
---|
45 | %else
|
---|
46 | mov edx, [esp + 4h]
|
---|
47 | mov eax, [esp]
|
---|
48 | mov [edx + 00h], eax ; eip
|
---|
49 | lea ecx, [esp + 4h]
|
---|
50 | mov [edx + 04h], ecx ; esp
|
---|
51 | mov [edx + 08h], ebp
|
---|
52 | mov [edx + 0ch], ebx
|
---|
53 | mov [edx + 10h], edi
|
---|
54 | mov [edx + 14h], esi
|
---|
55 | %endif
|
---|
56 | xor eax, eax
|
---|
57 | ret
|
---|
58 | ENDPROC RT_NOCRT(setjmp)
|
---|
59 |
|
---|
60 |
|
---|
61 | BEGINPROC RT_NOCRT(longjmp)
|
---|
62 | %ifdef RT_ARCH_AMD64
|
---|
63 | mov rbx, [rdi + 38h]
|
---|
64 | mov r12, [rdi + 30h]
|
---|
65 | mov r13, [rdi + 28h]
|
---|
66 | mov r14, [rdi + 20h]
|
---|
67 | mov r15, [rdi + 18h]
|
---|
68 | mov rbp, [rdi + 10h]
|
---|
69 | mov eax, esi
|
---|
70 | test eax, eax
|
---|
71 | jnz .fine
|
---|
72 | inc al
|
---|
73 | .fine:
|
---|
74 | mov rsp, [rdi + 08h]
|
---|
75 | jmp qword [rdi + 00h]
|
---|
76 | %else
|
---|
77 | mov edx, [esp + 4h]
|
---|
78 | mov eax, [esp + 8h]
|
---|
79 | mov esi, [edx + 14h]
|
---|
80 | mov edi, [edx + 10h]
|
---|
81 | mov ebx, [edx + 0ch]
|
---|
82 | mov ebp, [edx + 08h]
|
---|
83 | test eax, eax
|
---|
84 | jnz .fine
|
---|
85 | inc al
|
---|
86 | .fine:
|
---|
87 | mov esp, [edx + 04h]
|
---|
88 | jmp dword [edx + 00h]
|
---|
89 | %endif
|
---|
90 | ENDPROC RT_NOCRT(longjmp)
|
---|
91 |
|
---|