1 | ; $Id: tstHelpA.asm 19 2007-01-15 13:07:05Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; testcase helpers.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
|
---|
13 | ; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | ; distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | ; be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; If you received this file as part of a commercial VirtualBox
|
---|
18 | ; distribution, then only the terms of your commercial VirtualBox
|
---|
19 | ; license agreement apply instead of the previous paragraph.
|
---|
20 | ;
|
---|
21 |
|
---|
22 | %include "VBox/asmdefs.mac"
|
---|
23 | %include "VBox/cpum.mac"
|
---|
24 |
|
---|
25 | BEGINCODE
|
---|
26 |
|
---|
27 | ;;
|
---|
28 | ; Saves the current CPU context.
|
---|
29 | ;
|
---|
30 | ; @uses none
|
---|
31 | ; @param pCtx on stack. (Caller cleans up, as always.)
|
---|
32 | BEGINPROC TSTSaveCtx
|
---|
33 | push edx
|
---|
34 | mov edx, [esp + 8] ; argument.
|
---|
35 | mov [edx + CPUMCTX.eax], eax
|
---|
36 | mov [edx + CPUMCTX.ebx], ebx
|
---|
37 | mov [edx + CPUMCTX.ecx], ecx
|
---|
38 | pop dword [edx + CPUMCTX.edx]
|
---|
39 | mov [edx + CPUMCTX.edi], edi
|
---|
40 | mov [edx + CPUMCTX.esi], esi
|
---|
41 | mov [edx + CPUMCTX.ebp], ebp
|
---|
42 | mov [edx + CPUMCTX.esp], esp
|
---|
43 | ;mov eax, [esp] ....not this one...
|
---|
44 | ;mov [edx + CPUMCTX.eip], eax
|
---|
45 | xor eax, eax
|
---|
46 | mov eax, ss
|
---|
47 | mov [edx + CPUMCTX.ss], eax
|
---|
48 | mov eax, cs
|
---|
49 | mov [edx + CPUMCTX.cs], eax
|
---|
50 | mov eax, ds
|
---|
51 | mov [edx + CPUMCTX.ds], eax
|
---|
52 | mov eax, es
|
---|
53 | mov [edx + CPUMCTX.es], eax
|
---|
54 | mov eax, fs
|
---|
55 | mov [edx + CPUMCTX.fs], eax
|
---|
56 | mov eax, gs
|
---|
57 | mov [edx + CPUMCTX.gs], eax
|
---|
58 | pushfd
|
---|
59 | pop eax
|
---|
60 | mov [edx + CPUMCTX.eflags], eax
|
---|
61 | fxsave [edx + CPUMCTX.fpu]
|
---|
62 | mov eax, [edx + CPUMCTX.eax]
|
---|
63 | mov edx, [edx + CPUMCTX.edx]
|
---|
64 | ret
|
---|
65 | ENDPROC TSTSaveCtx
|
---|
66 |
|
---|
67 |
|
---|
68 | ;;
|
---|
69 | ; Compares two context structures.
|
---|
70 | ; @returns eax == 0 if equal.
|
---|
71 | ; @returns eax != 0 if different.
|
---|
72 | ; @param pCtx1 on stack.
|
---|
73 | ; @param pCtx2 on stack.
|
---|
74 | ; @uses nothing but eax and flags.
|
---|
75 | ;
|
---|
76 | BEGINPROC TSTCompareCtx
|
---|
77 | push esi
|
---|
78 | push edi
|
---|
79 | push ecx
|
---|
80 |
|
---|
81 | mov esi, [esp + 10h] ; pCtx1
|
---|
82 | mov edi, [esp + 14h] ; pCtx2
|
---|
83 | mov ecx, CPUMCTX_size >> 2
|
---|
84 | repz cmpsd
|
---|
85 | jz return
|
---|
86 |
|
---|
87 | shl ecx, 2
|
---|
88 | mov eax, CPUMCTX_size + 1
|
---|
89 | sub eax, ecx ; field offset + 1 byte.
|
---|
90 |
|
---|
91 | pop ecx
|
---|
92 | pop edi
|
---|
93 | pop esi
|
---|
94 | ret
|
---|
95 |
|
---|
96 | return:
|
---|
97 | xor eax, eax
|
---|
98 | pop ecx
|
---|
99 | pop edi
|
---|
100 | pop esi
|
---|
101 | ret
|
---|
102 | ENDPROC TSTCompareCtx
|
---|
103 |
|
---|