VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/misc/setjmp.asm@ 65208

Last change on this file since 65208 was 62477, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1; $Id: setjmp.asm 62477 2016-07-22 18:27:37Z vboxsync $
2;; @file
3; IPRT - No-CRT setjmp & longjmp - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2016 Oracle Corporation
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
30BEGINCODE
31
32
33;;
34; @param x86:[esp+4] msc:rcx gcc:rdi The jump buffer pointer.
35BEGINPROC RT_NOCRT(setjmp)
36%ifdef RT_ARCH_AMD64
37 %ifndef ASM_CALL64_MSC
38 mov rcx, rdi
39 %endif
40 mov rax, [rsp]
41 mov [rcx + 0h*8], rax ; 0 - rip
42 lea rdx, [rsp + 8]
43 mov [rcx + 1h*8], rdx ; 1 - rsp
44 mov [rcx + 2h*8], rbp
45 mov [rcx + 3h*8], r15
46 mov [rcx + 4h*8], r14
47 mov [rcx + 5h*8], r13
48 mov [rcx + 6h*8], r12
49 mov [rcx + 7h*8], rbx
50 %ifdef ASM_CALL64_MSC
51 mov [rcx + 8h*8], rsi
52 mov [rcx + 9h*8], rdi
53 movdqa [rcx + 0ah*8], xmm6
54 movdqa [rcx + 0ch*8], xmm7
55 movdqa [rcx + 0eh*8], xmm8
56 movdqa [rcx + 10h*8], xmm9
57 movdqa [rcx + 12h*8], xmm10
58 movdqa [rcx + 14h*8], xmm11
59 movdqa [rcx + 16h*8], xmm12
60 movdqa [rcx + 18h*8], xmm13
61 movdqa [rcx + 1ah*8], xmm14
62 movdqa [rcx + 1ch*8], xmm15
63 %ifndef RT_OS_WINDOWS
64 %error "Fix setjmp.h"
65 %endif
66 %endif
67%else
68 mov edx, [esp + 4h]
69 mov eax, [esp]
70 mov [edx + 0h*4], eax ; eip
71 lea ecx, [esp + 4h]
72 mov [edx + 1h*4], ecx ; esp
73 mov [edx + 2h*4], ebp
74 mov [edx + 3h*4], ebx
75 mov [edx + 4h*4], edi
76 mov [edx + 5h*4], esi
77%endif
78 xor eax, eax
79 ret
80ENDPROC RT_NOCRT(setjmp)
81
82
83;;
84; @param x86:[esp+4] msc:rcx gcc:rdi The jump buffer pointer.
85; @param x86:[esp+8] msc:rdx gcc:rsi Return value.
86BEGINPROC RT_NOCRT(longjmp)
87%ifdef RT_ARCH_AMD64
88 %ifdef ASM_CALL64_MSC
89 mov eax, edx ; ret
90 %else
91 mov rcx, rdi ; jmp_buf
92 mov eax, esi ; ret
93 %endif
94 mov rbp, [rcx + 2h*8]
95 mov r15, [rcx + 3h*8]
96 mov r14, [rcx + 4h*8]
97 mov r13, [rcx + 5h*8]
98 mov r12, [rcx + 6h*8]
99 mov rbx, [rcx + 7h*8]
100 %ifdef ASM_CALL64_MSC
101 mov rsi, [rcx + 8h*8]
102 mov rdi, [rcx + 9h*8]
103 movdqa xmm6, [rcx + 0ah*8]
104 movdqa xmm7, [rcx + 0ch*8]
105 movdqa xmm8, [rcx + 0eh*8]
106 movdqa xmm9, [rcx + 10h*8]
107 movdqa xmm10, [rcx + 12h*8]
108 movdqa xmm11, [rcx + 14h*8]
109 movdqa xmm12, [rcx + 16h*8]
110 movdqa xmm13, [rcx + 18h*8]
111 movdqa xmm14, [rcx + 1ah*8]
112 movdqa xmm15, [rcx + 1ch*8]
113 %ifndef RT_OS_WINDOWS
114 %error "Fix setjmp.h"
115 %endif
116 %endif
117 test eax, eax
118 jnz .fine
119 inc al
120.fine:
121 mov rsp, [rcx + 1h*8]
122 jmp qword [rcx + 0h*8]
123%else
124 mov edx, [esp + 4h] ; jmp_buf
125 mov eax, [esp + 8h] ; ret
126 mov esi, [edx + 5h*4]
127 mov edi, [edx + 4h*4]
128 mov ebx, [edx + 3h*4]
129 mov ebp, [edx + 2h*4]
130 test eax, eax
131 jnz .fine
132 inc al
133.fine:
134 mov esp, [edx + 1h*4]
135 jmp dword [edx+ 0h*4]
136%endif
137ENDPROC RT_NOCRT(longjmp)
138
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette