VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.4 KB
Line 
1; $Id: setjmp.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; IPRT - No-CRT setjmp & longjmp - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37%include "iprt/asmdefs.mac"
38
39
40BEGINCODE
41
42
43;;
44; @param x86:[esp+4] msc:rcx gcc:rdi The jump buffer pointer.
45RT_NOCRT_BEGINPROC setjmp
46%ifdef RT_ARCH_AMD64
47 %ifndef ASM_CALL64_MSC
48 mov rcx, rdi
49 %endif
50 mov rax, [rsp]
51 mov [rcx + 0h*8], rax ; 0 - rip
52 lea rdx, [rsp + 8]
53 mov [rcx + 1h*8], rdx ; 1 - rsp
54 mov [rcx + 2h*8], rbp
55 mov [rcx + 3h*8], r15
56 mov [rcx + 4h*8], r14
57 mov [rcx + 5h*8], r13
58 mov [rcx + 6h*8], r12
59 mov [rcx + 7h*8], rbx
60 %ifdef ASM_CALL64_MSC
61 mov [rcx + 8h*8], rsi
62 mov [rcx + 9h*8], rdi
63 movdqa [rcx + 0ah*8], xmm6
64 movdqa [rcx + 0ch*8], xmm7
65 movdqa [rcx + 0eh*8], xmm8
66 movdqa [rcx + 10h*8], xmm9
67 movdqa [rcx + 12h*8], xmm10
68 movdqa [rcx + 14h*8], xmm11
69 movdqa [rcx + 16h*8], xmm12
70 movdqa [rcx + 18h*8], xmm13
71 movdqa [rcx + 1ah*8], xmm14
72 movdqa [rcx + 1ch*8], xmm15
73 %ifndef RT_OS_WINDOWS
74 %error "Fix setjmp.h"
75 %endif
76 %endif
77%else
78 mov edx, [esp + 4h]
79 mov eax, [esp]
80 mov [edx + 0h*4], eax ; eip
81 lea ecx, [esp + 4h]
82 mov [edx + 1h*4], ecx ; esp
83 mov [edx + 2h*4], ebp
84 mov [edx + 3h*4], ebx
85 mov [edx + 4h*4], edi
86 mov [edx + 5h*4], esi
87%endif
88 xor eax, eax
89 ret
90ENDPROC RT_NOCRT(setjmp)
91
92
93;;
94; @param x86:[esp+4] msc:rcx gcc:rdi The jump buffer pointer.
95; @param x86:[esp+8] msc:rdx gcc:rsi Return value.
96RT_NOCRT_BEGINPROC longjmp
97%ifdef RT_ARCH_AMD64
98 %ifdef ASM_CALL64_MSC
99 mov eax, edx ; ret
100 %else
101 mov rcx, rdi ; jmp_buf
102 mov eax, esi ; ret
103 %endif
104 mov rbp, [rcx + 2h*8]
105 mov r15, [rcx + 3h*8]
106 mov r14, [rcx + 4h*8]
107 mov r13, [rcx + 5h*8]
108 mov r12, [rcx + 6h*8]
109 mov rbx, [rcx + 7h*8]
110 %ifdef ASM_CALL64_MSC
111 mov rsi, [rcx + 8h*8]
112 mov rdi, [rcx + 9h*8]
113 movdqa xmm6, [rcx + 0ah*8]
114 movdqa xmm7, [rcx + 0ch*8]
115 movdqa xmm8, [rcx + 0eh*8]
116 movdqa xmm9, [rcx + 10h*8]
117 movdqa xmm10, [rcx + 12h*8]
118 movdqa xmm11, [rcx + 14h*8]
119 movdqa xmm12, [rcx + 16h*8]
120 movdqa xmm13, [rcx + 18h*8]
121 movdqa xmm14, [rcx + 1ah*8]
122 movdqa xmm15, [rcx + 1ch*8]
123 %ifndef RT_OS_WINDOWS
124 %error "Fix setjmp.h"
125 %endif
126 %endif
127 test eax, eax
128 jnz .fine
129 inc al
130.fine:
131 mov rsp, [rcx + 1h*8]
132 jmp qword [rcx + 0h*8]
133%else
134 mov edx, [esp + 4h] ; jmp_buf
135 mov eax, [esp + 8h] ; ret
136 mov esi, [edx + 5h*4]
137 mov edi, [edx + 4h*4]
138 mov ebx, [edx + 3h*4]
139 mov ebp, [edx + 2h*4]
140 test eax, eax
141 jnz .fine
142 inc al
143.fine:
144 mov esp, [edx + 1h*4]
145 jmp dword [edx+ 0h*4]
146%endif
147ENDPROC RT_NOCRT(longjmp)
148
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use