1 | ; $Id: tstX86-FpuSaveRestoreA.asm 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; tstX86-FpuSaveRestore - Experimenting with saving and restoring FPU, assembly bits.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2013-2020 Oracle Corporation
|
---|
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 (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 |
|
---|
19 |
|
---|
20 | ;*******************************************************************************
|
---|
21 | ;* Header Files *
|
---|
22 | ;*******************************************************************************
|
---|
23 | %include "iprt/asmdefs.mac"
|
---|
24 | %include "iprt/x86.mac"
|
---|
25 |
|
---|
26 |
|
---|
27 | ;*******************************************************************************
|
---|
28 | ;* Global Variables *
|
---|
29 | ;*******************************************************************************
|
---|
30 | BEGINCODE
|
---|
31 | g_r80_Zero: dt 0.0
|
---|
32 | g_r80_One: dt 1.0
|
---|
33 |
|
---|
34 |
|
---|
35 | BEGINCODE
|
---|
36 |
|
---|
37 | ;; Prepares a FPU exception.
|
---|
38 | BEGINPROC MyFpuPrepXcpt
|
---|
39 | fld tword [g_r80_One xWrtRIP]
|
---|
40 | fld tword [g_r80_Zero xWrtRIP]
|
---|
41 | fdiv st0
|
---|
42 | ret
|
---|
43 | ENDPROC MyFpuPrepXcpt
|
---|
44 |
|
---|
45 |
|
---|
46 | ;; Same as above, just different address.
|
---|
47 | BEGINPROC MyFpuPrepXcpt2
|
---|
48 | fld tword [g_r80_One xWrtRIP]
|
---|
49 | fld tword [g_r80_Zero xWrtRIP]
|
---|
50 | fdiv st0
|
---|
51 | ret
|
---|
52 | ENDPROC MyFpuPrepXcpt2
|
---|
53 |
|
---|
54 |
|
---|
55 | BEGINPROC MyFpuSave
|
---|
56 | %ifdef ASM_CALL64_MSC
|
---|
57 | o64 fxsave [rcx]
|
---|
58 | %elifdef ASM_CALL64_GCC
|
---|
59 | o64 fxsave [rdi]
|
---|
60 | %elifdef RT_ARCH_X86
|
---|
61 | mov ecx, [esp + 4]
|
---|
62 | fxsave [ecx]
|
---|
63 | %else
|
---|
64 | %error "Unsupported architecture."
|
---|
65 | bad arch
|
---|
66 | %endif
|
---|
67 | ret
|
---|
68 | ENDPROC MyFpuSave
|
---|
69 |
|
---|
70 |
|
---|
71 | BEGINPROC MyFpuStoreEnv
|
---|
72 | %ifdef ASM_CALL64_MSC
|
---|
73 | fstenv [rcx]
|
---|
74 | %elifdef ASM_CALL64_GCC
|
---|
75 | fstenv [rdi]
|
---|
76 | %elifdef RT_ARCH_X86
|
---|
77 | mov ecx, [esp + 4]
|
---|
78 | fstenv [ecx]
|
---|
79 | %else
|
---|
80 | %error "Unsupported architecture."
|
---|
81 | bad arch
|
---|
82 | %endif
|
---|
83 | ret
|
---|
84 | ENDPROC MyFpuStoreEnv
|
---|
85 |
|
---|
86 |
|
---|
87 | BEGINPROC MyFpuRestore
|
---|
88 | %ifdef ASM_CALL64_MSC
|
---|
89 | o64 fxrstor [rcx]
|
---|
90 | %elifdef ASM_CALL64_GCC
|
---|
91 | o64 fxrstor [rdi]
|
---|
92 | %elifdef RT_ARCH_X86
|
---|
93 | mov ecx, [esp + 4]
|
---|
94 | fxrstor [ecx]
|
---|
95 | %else
|
---|
96 | %error "Unsupported architecture."
|
---|
97 | bad arch
|
---|
98 | %endif
|
---|
99 | ret
|
---|
100 | ENDPROC MyFpuRestore
|
---|
101 |
|
---|
102 |
|
---|
103 | BEGINPROC MyFpuLoadEnv
|
---|
104 | %ifdef ASM_CALL64_MSC
|
---|
105 | fldenv [rcx]
|
---|
106 | %elifdef ASM_CALL64_GCC
|
---|
107 | fldenv [rdi]
|
---|
108 | %elifdef RT_ARCH_X86
|
---|
109 | mov ecx, [esp + 4]
|
---|
110 | fldenv [ecx]
|
---|
111 | %else
|
---|
112 | %error "Unsupported architecture."
|
---|
113 | bad arch
|
---|
114 | %endif
|
---|
115 | ret
|
---|
116 | ENDPROC MyFpuLoadEnv
|
---|
117 |
|
---|