VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/cpu/rdtsc-asm.asm@ 90780

Last change on this file since 90780 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1; $Id: rdtsc-asm.asm 82968 2020-02-04 10:35:17Z vboxsync $
2;; @file
3; RDTSC test, assembly code
4;
5
6;
7; Copyright (C) 2009-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; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27
28;*********************************************************************************************************************************
29;* Header Files *
30;*********************************************************************************************************************************
31%include "iprt/asmdefs.mac"
32%include "iprt/x86.mac"
33
34
35;*********************************************************************************************************************************
36;* Global Variables *
37;*********************************************************************************************************************************
38BEGINDATA
39;;
40; Where DoTscReads() returns the rdtsc values.
41;
42; @note The results are 32-bit value pairs in x86 mode and 64-bit pairs in
43; AMD64 mode.
44GLOBALNAME g_aRdTscResults
45%ifdef RT_ARCH_AMD64
46 dq 0, 0
47 dq 0, 0 ; first value stored
48 dq 0, 0
49 dq 0, 0
50 dq 0, 0
51 dq 0, 0
52 dq 0, 0
53%else
54 dq 0, 0
55 dd 0, 0 ; first value stored
56 dd 0, 0
57 dd 0, 0
58%endif
59
60
61BEGINCODE
62
63;; Takes no arguments, returns number of values read into g_aRdTscResults.
64BEGINPROC DoTscReads
65 push xBP
66 mov xBP, xSP
67%ifdef RT_ARCH_AMD64
68 mov rax, 0feedfacecafebabeh
69 mov rdx, 0cafebabefeedfaceh
70 mov r8, 0deadbeef0deadbeefh
71 mov r9, 0deadbeef0deadbeefh
72 mov r10, 0deadbeef0deadbeefh
73 mov r11, 0deadbeef0deadbeefh
74 push rbx
75 push r12
76 push r13
77 push r14
78 push r15
79
80 ; Read 6x TSC into registers.
81 rdtsc
82 mov r8, rax
83 mov r9, rdx
84 rdtsc
85 mov r10, rax
86 mov r11, rdx
87 rdtsc
88 mov r12, rax
89 mov r13, rdx
90 rdtsc
91 mov r14, rax
92 mov r15, rdx
93 rdtsc
94 mov rbx, rax
95 mov rcx, rdx
96 rdtsc
97
98 ; Store the values (64-bit).
99 mov [NAME(g_aRdTscResults) + 10h xWrtRIP], r8
100 mov [NAME(g_aRdTscResults) + 18h xWrtRIP], r9
101 mov [NAME(g_aRdTscResults) + 20h xWrtRIP], r10
102 mov [NAME(g_aRdTscResults) + 28h xWrtRIP], r11
103 mov [NAME(g_aRdTscResults) + 30h xWrtRIP], r12
104 mov [NAME(g_aRdTscResults) + 38h xWrtRIP], r13
105 mov [NAME(g_aRdTscResults) + 40h xWrtRIP], r14
106 mov [NAME(g_aRdTscResults) + 48h xWrtRIP], r15
107 mov [NAME(g_aRdTscResults) + 50h xWrtRIP], rbx
108 mov [NAME(g_aRdTscResults) + 58h xWrtRIP], rcx
109 mov [NAME(g_aRdTscResults) + 60h xWrtRIP], rax
110 mov [NAME(g_aRdTscResults) + 68h xWrtRIP], rdx
111
112 pop r15
113 pop r14
114 pop r13
115 pop r12
116 pop rbx
117
118 mov eax, 6
119%else
120 mov eax, 0feedfaceh
121 mov edx, 0cafebabeh
122 push esi
123 push edi
124 push ebx
125
126 ; Read 3x TSC into registers.
127 rdtsc
128 mov ebx, eax
129 mov ecx, edx
130 rdtsc
131 mov esi, eax
132 mov edi, edx
133 rdtsc
134
135 ; Store values.
136 mov [NAME(g_aRdTscResults) + 08h], ebx
137 mov [NAME(g_aRdTscResults) + 0ch], ecx
138 mov [NAME(g_aRdTscResults) + 10h], esi
139 mov [NAME(g_aRdTscResults) + 14h], edi
140 mov [NAME(g_aRdTscResults) + 18h], eax
141 mov [NAME(g_aRdTscResults) + 1ch], edx
142
143 pop ebx
144 pop edi
145 pop esi
146
147 mov eax, 3
148%endif
149 leave
150 ret
151ENDPROC DoTscReads
152
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