VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstHelpA.asm@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

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