tstHelpA.asm revision 23df95deff774c30a68bea6ca1543293a4c5322f
4006N/A; $Id$
4006N/A;; @file
4006N/A; testcase helpers.
4006N/A;
363N/A
363N/A;
363N/A; Copyright (C) 2006 InnoTek Systemberatung GmbH
363N/A;
363N/A; This file is part of VirtualBox Open Source Edition (OSE), as
363N/A; available from http://www.virtualbox.org. This file is free software;
363N/A; you can redistribute it and/or modify it under the terms of the GNU
363N/A; General Public License as published by the Free Software Foundation,
363N/A; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
363N/A; distribution. VirtualBox OSE is distributed in the hope that it will
363N/A; be useful, but WITHOUT ANY WARRANTY of any kind.
7161N/A;
363N/A; If you received this file as part of a commercial VirtualBox
363N/A; distribution, then only the terms of your commercial VirtualBox
363N/A; license agreement apply instead of the previous paragraph.
363N/A;
363N/A
363N/A%include "VBox/asmdefs.mac"
363N/A%include "VBox/cpum.mac"
7161N/A
363N/ABEGINCODE
363N/A
363N/A;;
363N/A; Saves the current CPU context.
363N/A;
363N/A; @uses none
363N/A; @param pCtx on stack. (Caller cleans up, as always.)
363N/ABEGINPROC TSTSaveCtx
363N/A push edx
363N/A mov edx, [esp + 8] ; argument.
7161N/A mov [edx + CPUMCTX.eax], eax
363N/A mov [edx + CPUMCTX.ebx], ebx
363N/A mov [edx + CPUMCTX.ecx], ecx
363N/A pop dword [edx + CPUMCTX.edx]
363N/A mov [edx + CPUMCTX.edi], edi
363N/A mov [edx + CPUMCTX.esi], esi
363N/A mov [edx + CPUMCTX.ebp], ebp
363N/A mov [edx + CPUMCTX.esp], esp
363N/A ;mov eax, [esp] ....not this one...
363N/A ;mov [edx + CPUMCTX.eip], eax
363N/A xor eax, eax
7161N/A mov eax, ss
363N/A mov [edx + CPUMCTX.ss], eax
363N/A mov eax, cs
363N/A mov [edx + CPUMCTX.cs], eax
363N/A mov eax, ds
363N/A mov [edx + CPUMCTX.ds], eax
363N/A mov eax, es
363N/A mov [edx + CPUMCTX.es], eax
363N/A mov eax, fs
mov [edx + CPUMCTX.fs], eax
mov eax, gs
mov [edx + CPUMCTX.gs], eax
pushfd
pop eax
mov [edx + CPUMCTX.eflags], eax
fxsave [edx + CPUMCTX.fpu]
mov eax, [edx + CPUMCTX.eax]
mov edx, [edx + CPUMCTX.edx]
ret
ENDPROC TSTSaveCtx
;;
; Compares two context structures.
; @returns eax == 0 if equal.
; @returns eax != 0 if different.
; @param pCtx1 on stack.
; @param pCtx2 on stack.
; @uses nothing but eax and flags.
;
BEGINPROC TSTCompareCtx
push esi
push edi
push ecx
mov esi, [esp + 10h] ; pCtx1
mov edi, [esp + 14h] ; pCtx2
mov ecx, CPUMCTX_size >> 2
repz cmpsd
jz return
shl ecx, 2
mov eax, CPUMCTX_size + 1
sub eax, ecx ; field offset + 1 byte.
pop ecx
pop edi
pop esi
ret
return:
xor eax, eax
pop ecx
pop edi
pop esi
ret
ENDPROC TSTCompareCtx