VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/Instructions/env-common.mac@ 46860

最後變更 在這個檔案從46860是 46856,由 vboxsync 提交於 12 年 前

8-bit high register hell (reg/reg only so far).

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.8 KB
 
1; $Id: env-common.mac 46856 2013-06-28 03:03:19Z vboxsync $
2;; @file
3; Instruction Test Environment - Common Bits.
4;
5
6;
7; Copyright (C) 2006-2013 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.alldomusa.eu.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
18%ifndef ___env_common_mac
19%define ___env_common_mac
20
21
22;*******************************************************************************
23;* Defined Constants And Macros *
24;*******************************************************************************
25%ifdef RT_ARCH_AMD64
26 %define MY_PUSH_FLAGS pushfq
27 %define MY_POP_FLAGS popfq
28 %define MY_PUSH_FLAGS_SIZE 8
29
30 %macro MY_PUSH_ALL 0
31 push rbp
32 mov rbp, rsp
33 push rax
34 push rbx
35 push rcx
36 push rdx
37 push rsi
38 push rdi
39 push r8
40 push r9
41 push r10
42 push r11
43 push r12
44 push r13
45 push r14
46 push r15
47 pushfq
48 %endm
49 %macro MY_POP_ALL 0
50 popfq
51 pop r15
52 pop r14
53 pop r13
54 pop r12
55 pop r11
56 pop r10
57 pop r9
58 pop r8
59 pop rdi
60 pop rsi
61 pop rdx
62 pop rcx
63 pop rbx
64 pop rax
65 pop rbp
66 %endm
67
68%else
69 %define MY_PUSH_FLAGS pushfd
70 %define MY_POP_FLAGS popfd
71 %define MY_PUSH_FLAGS_SIZE 4
72
73 %macro MY_PUSH_ALL 0
74 push eBP
75 mov xBP, xSP
76 push eax
77 push ebx
78 push ecx
79 push edx
80 push esi
81 push edi
82 pushfd
83 %endm
84 %macro MY_POP_ALL 0
85 popfd
86 pop edi
87 pop esi
88 pop edx
89 pop ecx
90 pop ebx
91 pop eax
92 pop ebp
93 %endm
94%endif
95
96
97
98;*******************************************************************************
99;* Internal Functions *
100;*******************************************************************************
101
102VBINSTST_BEGINCODE
103
104;;
105; Report bad register value.
106;
107; Primary purpose is save all registers and convert from our stack-based to
108; the correct calling convention for the environment.
109;
110; @param uExpected
111; @param uActual
112; @param uRegisterNo
113;
114VBINSTST_BEGINPROC Common_BadValue
115 MY_PUSH_ALL
116 mov xAX, xSP ; 16-byte align the stack and reserve space for arguments and stuff.
117 sub xSP, 40h
118 and xSP, ~15
119 mov [xSP + 38h], xAX
120
121%ifdef ASM_CALL64_GCC
122 mov r8d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
123 mov rcx, [rbp + 10h] ; expected
124 mov rdx, [rbp + 18h] ; actual
125 mov rsi, [rbp + 20h] ; reg#
126 lea rdi, [.szFmt wrt rip]
127 VBINSTST_CALL_FN_FAILURE_4
128
129%elifdef ASM_CALL64_MSC
130 mov r10d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
131 mov [rsp + 20h], r10
132 mov r9, [rbp + 10h] ; expected
133 mov r8, [rbp + 18h] ; actual
134 mov rdx, [rbp + 20h] ; reg#
135 lea rcx, [.szFmt wrt rip]
136 VBINSTST_CALL_FN_FAILURE_4
137
138%else
139 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator)]
140 mov sCX, [xBP + 4 + xCB] ; expected
141 mov sAX, [xBP + 4 + xCB + 4] ; actual
142 mov sDX, [xBP + 4 + xCB + 8] ; reg#
143 mov [xSP + xCB + 3*sCB], sBX
144 mov [xSP + xCB + 2*sCB], sCX
145 mov [xSP + xCB + 1*sCB], sAX
146 mov [xSP + xCB], sDX
147 mov [xSP], RTCCPTR_PRE .szFmt
148 VBINSTST_CALL_FN_FAILURE_4
149%endif
150
151 mov xSP, [xSP + 38h]
152 MY_POP_ALL
153 ret
154%if ARCH_BITS == 64
155.szFmt: db 'Bad register %#llx value %#018llx, expected %#018llx (line %llu)', 0
156%else
157.szFmt: db 'Bad register %lx value %#010lx, expected %#010lx (line %lu)', 0
158%endif
159VBINSTST_ENDPROC Common_BadValue
160
161
162
163;
164; Global data variables used by Common_SetupMemReadUxx.
165;
166BEGINDATA
167VBINSTST_GLOBALNAME_EX g_u64Data, data hidden
168 dq 0
169VBINSTST_GLOBALNAME_EX g_u32Data, data hidden
170 dd 0
171VBINSTST_GLOBALNAME_EX g_u16Data, data hidden
172 dw 0
173VBINSTST_GLOBALNAME_EX g_u8Data, data hidden
174 db 0
175 db 90h
176
177BEGINCODE
178
179;;
180; Sets up g_u8Data.
181; @param uValue
182VBINSTST_BEGINPROC Common_SetupMemReadU8
183 push sAX
184 mov ax, [xSP + sCB + xCB]
185 mov [VBINSTST_NAME(g_u8Data) xWrtRIP], ax
186 pop sAX
187 ret sCB
188VBINSTST_ENDPROC Common_SetupMemReadU8
189
190;;
191; Sets up g_u16Data.
192; @param uValue
193VBINSTST_BEGINPROC Common_SetupMemReadU16
194 push sAX
195 mov ax, [xSP + sCB + xCB]
196 mov [VBINSTST_NAME(g_u16Data) xWrtRIP], ax
197 pop sAX
198 ret sCB
199VBINSTST_ENDPROC Common_SetupMemReadU16
200
201;;
202; Sets up g_u32Data.
203; @param uValue
204VBINSTST_BEGINPROC Common_SetupMemReadU32
205 push sAX
206 mov eax, [xSP + sCB + xCB]
207 mov [VBINSTST_NAME(g_u32Data) xWrtRIP], eax
208 pop sAX
209 ret sCB
210VBINSTST_ENDPROC Common_SetupMemReadU32
211
212;;
213; Sets up g_u64Data.
214; @param uValue
215VBINSTST_BEGINPROC Common_SetupMemReadU64
216 push sAX
217%ifdef RT_ARCH_AMD64
218 mov rax, [xSP + sCB + xCB]
219 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], rax
220%else
221 mov eax, [xSP + sCB + xCB]
222 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], eax
223 mov eax, [xSP + sCB + xCB + 4]
224 mov [VBINSTST_NAME(g_u64Data) + 4 xWrtRIP], eax
225%endif
226 pop sAX
227 ret sCB
228VBINSTST_ENDPROC Common_SetupMemReadU64
229
230
231%endif
232
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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